From 286fbafb561079140494a99923f3897f3a451910 Mon Sep 17 00:00:00 2001 From: JohnMTorgerson Date: Sun, 16 May 2021 14:26:01 -0500 Subject: [PATCH 1/2] changed acceptable_values for bulb temp to range(1800, 6500 + 1), fixed typo in variable name in error raised for out of bounds temperature assignment --- wyze_sdk/models/__init__.py | 2 +- wyze_sdk/models/devices/bulbs.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wyze_sdk/models/__init__.py b/wyze_sdk/models/__init__.py index af04342..b8c7d25 100644 --- a/wyze_sdk/models/__init__.py +++ b/wyze_sdk/models/__init__.py @@ -230,4 +230,4 @@ def validate(self, value: Any): logging.debug(f"value {value} found in acceptable_values, passing") return - raise WyzeRequestError(f"{value} must be one of {self.acceptable_values}") + raise WyzeRequestError(f"{value} must be one of {self._acceptable_values}") diff --git a/wyze_sdk/models/devices/bulbs.py b/wyze_sdk/models/devices/bulbs.py index 1f417b0..136ac73 100644 --- a/wyze_sdk/models/devices/bulbs.py +++ b/wyze_sdk/models/devices/bulbs.py @@ -29,7 +29,7 @@ def brightness(cls) -> PropDef: @classmethod def color_temp(cls) -> PropDef: - return PropDef("P1502", int, acceptable_values=range(2700, 6500 + 1)) + return PropDef("P1502", int, acceptable_values=range(1800, 6500 + 1)) @classmethod def color(cls) -> PropDef: From 58fe8591f5e8d4b40bd02087352e80a68fbddd19 Mon Sep 17 00:00:00 2001 From: JohnMTorgerson Date: Sun, 16 May 2021 15:41:19 -0500 Subject: [PATCH 2/2] changed acceptable_values for bulb temp to range(1800, 6500 + 1) just for mesh bulbs, fixed typo in variable name in error raised for out of bounds temperature assignment --- wyze_sdk/api/devices/bulbs.py | 9 +++++++-- wyze_sdk/models/devices/bulbs.py | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/wyze_sdk/api/devices/bulbs.py b/wyze_sdk/api/devices/bulbs.py index 16766a5..f0373e6 100644 --- a/wyze_sdk/api/devices/bulbs.py +++ b/wyze_sdk/api/devices/bulbs.py @@ -145,10 +145,11 @@ def set_color_temp(self, *, device_mac: str, device_model: str, color_temp: int, :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: + prop_def = BulbProps.color_temp_mesh() + prop_def.validate(color_temp) + return super()._api_client().run_action_list( actions={ "key": "set_mesh_property", @@ -157,6 +158,10 @@ def set_color_temp(self, *, device_mac: str, device_model: str, color_temp: int, "provider_key": device_model, } ) + + prop_def = BulbProps.color_temp() + prop_def.validate(color_temp) + return super()._api_client().set_device_property( mac=device_mac, model=device_model, pid=prop_def.pid, value=color_temp) diff --git a/wyze_sdk/models/devices/bulbs.py b/wyze_sdk/models/devices/bulbs.py index 136ac73..34d0d16 100644 --- a/wyze_sdk/models/devices/bulbs.py +++ b/wyze_sdk/models/devices/bulbs.py @@ -29,6 +29,10 @@ def brightness(cls) -> PropDef: @classmethod def color_temp(cls) -> PropDef: + return PropDef("P1502", int, acceptable_values=range(2700, 6500 + 1)) + + @classmethod + def color_temp_mesh(cls) -> PropDef: return PropDef("P1502", int, acceptable_values=range(1800, 6500 + 1)) @classmethod