Set the thermostat mode.

        Mode optons:
            OFF = 0x00,
            HEAT = 0x01,
            COOL = 0x02,
            AUTO = 0x03,
            FAN_AUTO = 0x04,
            FAN_ALWAYS_ON = 0x8
509374
def set(self, mode):
        
        if mode == ThermostatMode.FAN_AUTO:
            new_mode = COMMAND_THERMOSTAT_CONTROL_OFF_FAN_0X6B_0X08
        elif mode == ThermostatMode.FAN_ALWAYS_ON:
            new_mode = COMMAND_THERMOSTAT_CONTROL_ON_FAN_0X6B_0X07
        if new_mode:
            msg = ExtendedSend(address=self._address,
                               commandtuple=new_mode,
                               userdata=Userdata())
            msg.set_checksum()
            self._send_method(msg, self._mode_change_ack)
1044832
def set_default(self, channels=None):
        '''
        '''
        if not channels:
            channels = self._ch_cal.keys()
        for channel in channels:
            self.set_voltage(channel, self._ch_cal[channel]['default'], unit='V')
977935
def set_mode_apm(self, mode, custom_mode = 0, custom_sub_mode = 0):
        ''''''
        if isinstance(mode, str):
            mode_map = self.mode_mapping()
            if mode_map is None or mode not in mode_map:
                print("Unknown mode '%s'" % mode)
                return
            mode = mode_map[mode]
        # set mode by integer mode number for ArduPilot
        self.mav.set_mode_send(self.target_system,
                               mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
                               mode)
1011881
def set_fan(self, fan):
        
        if type(fan) != int and fan not in range(0, 11):
            raise InvalidInput("Fan value must be int between 0-10")
        self._config['fan'] = fan
        self._q.put(self._config)
1144416
async def set_target_temp(self, temp, temporary=True,
                              timeout=OTGW_DEFAULT_TIMEOUT):
        
        cmd = (OTGW_CMD_TARGET_TEMP if temporary
               else OTGW_CMD_TARGET_TEMP_CONST)
        value = '{:2.1f}'.format(temp)
        status = {}
        ret = await self._wait_for_cmd(cmd, value, timeout)
        if ret is None:
            return
        ret = float(ret)
        if 0 <= ret <= 30:
            if ret == 0:
                status[OTGW_SETP_OVRD_MODE] = OTGW_SETP_OVRD_DISABLED
                status[DATA_ROOM_SETPOINT_OVRD] = None
            else:
                if temporary:
                    ovrd_mode = OTGW_SETP_OVRD_TEMPORARY
                else:
                    ovrd_mode = OTGW_SETP_OVRD_PERMANENT
                status[OTGW_SETP_OVRD_MODE] = ovrd_mode
                status[DATA_ROOM_SETPOINT_OVRD] = ret
            self._update_status(status)
            return ret
96073
def set_mode_loiter(self):
        ''''''
        if self.mavlink10():
            self.mav.command_long_send(self.target_system, self.target_component,
                                       mavlink.MAV_CMD_NAV_LOITER_UNLIM, 0, 0, 0, 0, 0, 0, 0, 0)
        else:
            MAV_ACTION_LOITER = 27
            self.mav.action_send(self.target_system, self.target_component, MAV_ACTION_LOITER)
618562
def set_hvac_mode(self, mode):
        """"""
        self.set_service_value(
            self.thermostat_operating_service,
            'ModeTarget',
            'NewModeTarget',
            mode)
        self.set_cache_value('mode', mode)
1317495
def set_heat_pump_mode(self, device_label, mode):
        
        response = None
        try:
            response = requests.put(
                urls.set_heatpump_state(self._giid, device_label),
                headers={
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                    'Cookie': 'vid={}'.format(self._vid)},
                data=json.dumps({'mode': mode}))
        except requests.exceptions.RequestException as ex:
            raise RequestError(ex)
        _validate_response(response)
        return json.loads(response.text)
854216
def update(self):
        """"""
        self._controller.update(self._id, wake_if_asleep=False)

        data = self._controller.get_climate_params(self._id)
        if data:
            if time.time() - self.__manual_update_time > 60:
                self.__is_auto_conditioning_on = (data
                                                  ['is_auto_conditioning_on'])
                self.__is_climate_on = data['is_climate_on']
                self.__driver_temp_setting = (data['driver_temp_setting']
                                              if data['driver_temp_setting']
                                              else self.__driver_temp_setting)
                self.__passenger_temp_setting = (data['passenger_temp_setting']
                                                 if
                                                 data['passenger_temp_setting']
                                                 else
                                                 self.__passenger_temp_setting)
            self.__inside_temp = (data['inside_temp'] if data['inside_temp']
                                  else self.__inside_temp)
            self.__outside_temp = (data['outside_temp'] if data['outside_temp']
                                   else self.__outside_temp)
            self.__fan_status = data['fan_status']
1211061
def set_state(self, state, speed=None):
        
        desired_state = {"powered": state}
        if state:
            brightness = self._to_brightness.get(speed or self.current_fan_speed(), 0.33)
            desired_state.update({'brightness': brightness})

        response = self.api_interface.set_device_state(self, {
            "desired_state": desired_state
        })

        self._update_state_from_response(response)
535063
def _set_dhw(self, status="Scheduled", mode=None, next_time=None):
        
        data = {"Status": status,
                "Mode": mode,
                "NextTime": next_time,
                "SpecialModes": None,
                "HeatSetpoint": None,
                "CoolSetpoint": None}

        self._populate_full_data()
        dhw_zone = self._get_dhw_zone()
        if dhw_zone is None:
            raise Exception('No DHW zone reported from API')
        url = (self.hostname + "/WebAPI/api/devices"
               "/%s/thermostat/changeableValues" % dhw_zone)

        response = self._do_request('put', url, json.dumps(data))

        task_id = self._get_task_id(response)

        while self._get_task_status(task_id) != 'Succeeded':
            time.sleep(1)
903858
def disableTemperature(self):
        
        logger.debug("Disabling temperature sensor")
        self.fifoSensorMask &= ~self.enableTemperatureMask
        self._setSampleSizeBytes()
809834
def set_mode_flag(self, flag, enable):
        '''
        
        '''
        if self.mavlink10():
            mode = self.base_mode
            if (enable == True):
                mode = mode | flag
            elif (enable == False):
                mode = mode & ~flag
            self.mav.command_long_send(self.target_system, self.target_component,
                                           mavlink.MAV_CMD_DO_SET_MODE, 0,
                                           mode,
                                           0, 0, 0, 0, 0, 0)
        else:
            print("Set mode flag not supported")
64683
def set_level(self, val):
        """"""
        speed = self._value_to_fan_speed(val)
        if val == 0:
            self.off()
        else:
            set_command = ExtendedSend(self._address,
                                       COMMAND_LIGHT_ON_0X11_NONE,
                                       self._udata, cmd2=speed)
            set_command.set_checksum()
            self._send_method(set_command, self._on_message_received)
321346
def call_heat(tstat):
    
    current_hsp, current_csp = tstat.heating_setpoint, tstat.cooling_setpoint
    current_temp = tstat.temperature
    tstat.write({
        'heating_setpoint': current_temp+10,
        'cooling_setpoint': current_temp+20,
        'mode': HEAT,
    })

    def restore():
        tstat.write({
            'heating_setpoint': current_hsp,
            'cooling_setpoint': current_csp,
            'mode': AUTO,
        })
    return restore
303780
def set_state(self, state, speed=None):
        
        speed = speed or self.current_fan_speed()
        if state:
            desired_state = {"powered": state, "mode": speed}
        else:
            desired_state = {"powered": state}

        response = self.api_interface.set_device_state(self, {
            "desired_state": desired_state
        })

        self._update_state_from_response(response)
223774
def set_hkr_state(self, state):
        
        try:
            value = {
                'off': 0,
                'on': 100,
                'eco': self.eco_temperature,
                'comfort': self.comfort_temperature
            }[state]
        except KeyError:
            return

        self.set_target_temperature(value)