'Set new target temperature.'

def set_temperature(self, **kwargs):

    set_req = self.gateway.const.SetReq
    temp = kwargs.get(ATTR_TEMPERATURE)
    low = kwargs.get(ATTR_TARGET_TEMP_LOW)
    high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
    heat = self._values.get(set_req.V_HVAC_SETPOINT_HEAT)
    cool = self._values.get(set_req.V_HVAC_SETPOINT_COOL)
    updates = ()
    if (temp is not None):
        if (heat is not None):
            value_type = set_req.V_HVAC_SETPOINT_HEAT
        elif (cool is not None):
            value_type = set_req.V_HVAC_SETPOINT_COOL
        if ((heat is not None) or (cool is not None)):
            updates = [(value_type, temp)]
    elif all(((val is not None) for val in (low, high, heat, cool))):
        updates = [(set_req.V_HVAC_SETPOINT_HEAT, low), (set_req.V_HVAC_SETPOINT_COOL, high)]
    for (value_type, value) in updates:
        self.gateway.set_child_value(self.node_id, self.child_id, value_type, value)
        if self.gateway.optimistic:
            self._values[value_type] = value
            self.schedule_update_ha_state()
