示例#1
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,
            })
示例#2
0
    def clear_timer(self, *, device_mac: str, device_model: str,
                    **kwargs) -> WyzeResponse:
        """Clears any existing power state timer on the bulb.

        :param str device_mac: The device mac. e.g. ``ABCDEF1234567890``
        :param str device_model: The device model. e.g. ``WLPA19``

        :rtype: WyzeResponse
        """
        if device_model in DeviceModels.MESH_BULB:
            raise WyzeFeatureNotSupportedError("clear_timer")
        return super()._api_client().cancel_device_timer(mac=device_mac,
                                                         action_type=1)
示例#3
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)
示例#4
0
 def color(self) -> str:
     raise WyzeFeatureNotSupportedError("color")