示例#1
0
    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),
        ])
示例#2
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()),
        ])
示例#3
0
    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,
            })
示例#4
0
    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),
        ])
示例#5
0
    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)
示例#6
0
    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),
        ])
示例#7
0
    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)
示例#8
0
 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)
示例#9
0
    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))
示例#10
0
    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))
示例#11
0
    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))
示例#12
0
    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))
示例#13
0
    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))
示例#14
0
    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))
示例#15
0
    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")
示例#16
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)
示例#17
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
示例#18
0
 def photosensitive_switch(self, value: Union[int, DeviceProp]):
     if isinstance(value, int):
         value = DeviceProp(definition=PlugProps.photosensitive_switch(),
                            value=value)
     self._photosensitive_switch = value
示例#19
0
 def away_mode(self, value: Union[int, DeviceProp]):
     if isinstance(value, int):
         value = DeviceProp(definition=PlugProps.away_mode(), value=value)
     self._away_mode = value
示例#20
0
 def unit(self, value: Union[str, DeviceProp]):
     if isinstance(value, str):
         value = DeviceProp(definition=ScaleProps.unit(), value=value)
     self._unit = value
示例#21
0
 def brightness(self, value: Union[int, DeviceProp]):
     if isinstance(value, int):
         value = DeviceProp(definition=BulbProps.brightness(), value=value)
     self._brightness = value
示例#22
0
 def color(self, value: Union[str, DeviceProp]):
     if isinstance(value, str):
         value = DeviceProp(definition=BulbProps.color(), value=value)
     self._color = value
示例#23
0
 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
示例#24
0
 def color_temp(self, value: Union[int, DeviceProp]):
     if isinstance(value, int):
         value = DeviceProp(definition=BulbProps.color_temp(), value=value)
     self._color_temp = value