def clear_hold(self, *, device_mac: str, device_model: str, **kwargs) -> WyzeResponse: """Clears any existing hold on the thermostat and resumes "smart" operations. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :rtype: WyzeResponse """ return self._set_thermostat_properties(device_mac, device_model, [ DeviceProp(definition=Thermostat.props()["asw_hold"], value=0), DeviceProp(definition=Thermostat.props()["device_hold"], value=0), DeviceProp(definition=Thermostat.props()["device_hold_time"], value=0), ])
def hold(self, *, device_mac: str, device_model: str, until: datetime, **kwargs) -> WyzeResponse: """Holds the current thermostat settings until a certain date/time. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :param datetime until: The new end date/time of the hold. :rtype: WyzeResponse """ return self._set_thermostat_properties(device_mac, device_model, [ DeviceProp(definition=Thermostat.props()["device_hold"], value=1), DeviceProp(definition=Thermostat.props()["device_hold_time"], value=until.timestamp()), ])
def set_color(self, *, device_mac: str, device_model: str, color: str, **kwargs) -> WyzeResponse: """Sets the color of a bulb. Args: :param str device_mac: The device mac. e.g. ``ABCDEF1234567890`` :param str device_model: The device model. e.g. ``WLPA19`` :param str color: The new color temperature. e.g. ``ff0000`` :rtype: WyzeResponse :raises WyzeFeatureNotSupportedError: If the bulb doesn't support color """ if device_model not in DeviceModels.MESH_BULB: raise WyzeFeatureNotSupportedError("set_color") prop_def = BulbProps.color()() prop_def.validate(color) return super()._api_client().run_action_list( actions={ "key": "set_mesh_property", "prop": DeviceProp(definition=prop_def, value=color), "device_mac": device_mac, "provider_key": device_model, })
def set_temperature(self, *, device_mac: str, device_model: str, cooling_setpoint: int, heating_setpoint: int, **kwargs) -> WyzeResponse: """Sets the heating and cooling setpoints of the thermostat. .. note:: Heating and cooling setpoints cannot be set independently via this method. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :param int cooling_setpoint: The new cooling setpoint. e.g. ``72`` :param int heating_setpoint: The new heating setpoint. e.g. ``68`` :rtype: WyzeResponse """ return self._set_thermostat_properties(device_mac, device_model, [ DeviceProp(definition=Thermostat.props()["cooling_setpoint"], value=cooling_setpoint), DeviceProp(definition=Thermostat.props()["heating_setpoint"], value=heating_setpoint), ])
def set_color_temp(self, *, device_mac: str, device_model: str, color_temp: int, **kwargs) -> WyzeResponse: """Sets the color temperature of a bulb. Args: :param str device_mac: The device mac. e.g. ``ABCDEF1234567890`` :param str device_model: The device model. e.g. ``WLPA19`` :param int color_temp: The new color temperature. e.g. ``3400`` :rtype: WyzeResponse :raises WyzeRequestError: if the new color temperature is not valid """ prop_def = BulbProps.color_temp() prop_def.validate(color_temp) if device_model in DeviceModels.MESH_BULB: return super()._api_client().run_action_list( actions={ "key": "set_mesh_property", "prop": DeviceProp(definition=PropDef(prop_def.pid, str), value=str(color_temp)), "device_mac": device_mac, "provider_key": device_model, }) return super()._api_client().set_device_property(mac=device_mac, model=device_model, pid=prop_def.pid, value=color_temp)
def set_mode(self, *, device_mac: str, device_model: str, system_mode: ThermostatSystemMode, fan_mode: ThermostatFanMode, **kwargs) -> WyzeResponse: """Sets the system and fan modes of the thermostat. .. note:: Fan mode and system mode cannot be set independently via this method. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :param ThermostatSystemMode system_mode: The new system mode. e.g. ``ThermostatSystemMode.AUTO`` :param ThermostatFanMode fan_mode: The new fan mode. e.g. ``ThermostatFanMode.CYCLE`` :rtype: WyzeResponse """ return self._set_thermostat_properties(device_mac, device_model, [ DeviceProp(definition=Thermostat.props()["fan_mode"], value=fan_mode.codes), DeviceProp(definition=Thermostat.props()["system_mode"], value=system_mode.codes), ])
def set_brightness(self, *, device_mac: str, device_model: str, brightness: int, **kwargs) -> WyzeResponse: """Sets the brightness of a bulb. :param str device_mac: The device mac. e.g. ``ABCDEF1234567890`` :param str device_model: The device model. e.g. ``WLPA19`` :param int brightness: The new brightness. e.g. ``45`` :rtype: WyzeResponse :raises WyzeRequestError: if the new brightness is not valid """ prop_def = BulbProps.brightness() prop_def.validate(brightness) if device_model in DeviceModels.MESH_BULB: return super()._api_client().run_action_list( actions={ "key": "set_mesh_property", "prop": DeviceProp(definition=prop_def, value=str(brightness)), "device_mac": device_mac, "provider_key": device_model, }) return super()._api_client().set_device_property(mac=device_mac, model=device_model, pid=prop_def.pid, value=brightness)
def __init__(self, *, event_list: Optional[Sequence[dict]] = None, **others: dict): super().__init__(type=self.type, **others) self.switch_state = super()._extract_property( DeviceProps.power_state(), others) self.motion_state = DeviceProp( definition=PropDef("", bool, bool), value=False ) # TODO: add support for parsing recent events to see if there's current motion self._temperature = super()._extract_attribute('temperature', others) self._humidity = super()._extract_attribute('humidity', others) self._voltage = super()._extract_property(CameraProps.voltage(), others) self._supports_audio_alarm = super()._extract_property( CameraProps.suppprts_audio_alarm(), others) self._supports_co_alarm = super()._extract_property( CameraProps.suppprts_co_alarm(), others) self._supports_motion_alarm = super()._extract_property( CameraProps.suppprts_motion_alarm(), others) self._suppprts_smoke_alarm = super()._extract_property( CameraProps.suppprts_smoke_alarm(), others) if event_list is not None: self.latest_events = event_list show_unknown_key_warning(self, others)
def set_system_mode(self, *, device_mac: str, device_model: str, system_mode: ThermostatSystemMode, **kwargs) -> WyzeResponse: """Sets the system mode of the thermostat. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :param ThermostatSystemMode system_mode: The new system mode. e.g. ``ThermostatSystemMode.AUTO`` :rtype: WyzeResponse """ return self._set_thermostat_property(device_mac, device_model, DeviceProp(definition=Thermostat.props()["system_mode"], value=system_mode.codes))
def set_heating_setpoint(self, *, device_mac: str, device_model: str, heating_setpoint: int, **kwargs) -> WyzeResponse: """Sets the heating setpoint of the thermostat. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :param int heating_setpoint: The new heating setpoint. e.g. ``68`` :rtype: WyzeResponse """ return self._set_thermostat_property(device_mac, device_model, DeviceProp(definition=Thermostat.props()["heating_setpoint"], value=heating_setpoint))
def set_current_scenario(self, *, device_mac: str, device_model: str, scenario: ThermostatScenarioType, **kwargs) -> WyzeResponse: """Sets the current scenario of the thermostat. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :param ThermostatScenarioType scenario: The new scenario. e.g. ``ThermostatScenarioType.HOME`` :rtype: WyzeResponse """ return self._set_thermostat_property(device_mac, device_model, DeviceProp(definition=Thermostat.props()["current_scenario"], value=scenario.codes))
def set_fan_mode(self, *, device_mac: str, device_model: str, fan_mode: ThermostatFanMode, **kwargs) -> WyzeResponse: """Sets the fan mode of the thermostat. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :param ThermostatFanMode fan_mode: The new fan mode. e.g. ``ThermostatFanMode.CYCLE`` :rtype: WyzeResponse """ return self._set_thermostat_property(device_mac, device_model, DeviceProp(definition=Thermostat.props()["fan_mode"], value=fan_mode.codes))
def set_lock(self, *, device_mac: str, device_model: str, locked: int, **kwargs) -> WyzeResponse: """Sets the device lock for a thermostat. If set, the thermostat can only be updated via the app and not by using the physical controls. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :param int locked (int): The new locked state. e.g. ``1`` :rtype: WyzeResponse """ return self._set_thermostat_property(device_mac, device_model, DeviceProp(definition=Thermostat.props()["locked"], value=locked))
def set_behavior(self, *, device_mac: str, device_model: str, behavior: int, **kwargs) -> WyzeResponse: """Sets the comfort balance behavior for a thermostat. This setting allows the user to toggle between preset behaviors for weighing cost savings vs. climate comfort. An update to this property will modify the device's scenario setpoints. :param str device_mac: The device mac. e.g. ``CO_EA1_ABCDEF1234567890`` :param str device_model: The device model. e.g. ``CO_EA1`` :param int behavior: The new behavior. e.g. ``1`` :rtype: WyzeResponse """ return self._set_thermostat_property(device_mac, device_model, DeviceProp(definition=Thermostat.props()["save_comfort_balance"], value=behavior))
def _set_away_mode_disbled(self, *, device_mac: str, device_model: str, **kwargs) -> WyzeResponse: prop_def = BulbProps.away_mode if device_model in DeviceModels.MESH_BULB: return super()._api_client().run_action_list( actions={ "key": "set_mesh_property", "prop": DeviceProp(definition=prop_def, value=False), "device_mac": device_mac, "provider_key": device_model, }) super()._api_client().set_device_property(mac=device_mac, model=device_model, pid=prop_def.pid, value="0")
def turn_off(self, *, device_mac: str, device_model: str, after: Optional[timedelta] = None, **kwargs) -> WyzeResponse: """Turns off a bulb. :param str device_mac: The device mac. e.g. ``ABCDEF1234567890`` :param str device_model: The device model. e.g. ``WLPA19`` :param timedelta after: The delay before performing the action. :rtype: WyzeResponse """ prop_def = DeviceProps.power_state() if device_model in DeviceModels.MESH_BULB: if after is not None: raise WyzeFeatureNotSupportedError("delayed power action") return super()._api_client().run_action_list( actions={ "key": "set_mesh_property", "prop": DeviceProp(definition=PropDef(prop_def.pid, str), value="0"), "device_mac": device_mac, "provider_key": device_model, }) if after is None: return super()._api_client().set_device_property( mac=device_mac, model=device_model, pid=prop_def.pid, value=0) return super()._api_client().set_device_timer(mac=device_mac, delay_time=after.seconds, action_type=1, action_value=0)
def status_light(self, value: Union[int, DeviceProp]): if isinstance(value, int): value = DeviceProp(definition=PlugProps.status_light(), value=value) self._status_light = value
def photosensitive_switch(self, value: Union[int, DeviceProp]): if isinstance(value, int): value = DeviceProp(definition=PlugProps.photosensitive_switch(), value=value) self._photosensitive_switch = value
def away_mode(self, value: Union[int, DeviceProp]): if isinstance(value, int): value = DeviceProp(definition=PlugProps.away_mode(), value=value) self._away_mode = value
def unit(self, value: Union[str, DeviceProp]): if isinstance(value, str): value = DeviceProp(definition=ScaleProps.unit(), value=value) self._unit = value
def brightness(self, value: Union[int, DeviceProp]): if isinstance(value, int): value = DeviceProp(definition=BulbProps.brightness(), value=value) self._brightness = value
def color(self, value: Union[str, DeviceProp]): if isinstance(value, str): value = DeviceProp(definition=BulbProps.color(), value=value) self._color = value
def power_loss_recovery(self, value: Union[int, DeviceProp]): if isinstance(value, int): value = DeviceProp(definition=BulbProps.power_loss_recovery(), value=value) self._power_loss_recovery = value
def color_temp(self, value: Union[int, DeviceProp]): if isinstance(value, int): value = DeviceProp(definition=BulbProps.color_temp(), value=value) self._color_temp = value