From c08b58cd8b2d4d8ce84a5967961c6dae6b88ca9a Mon Sep 17 00:00:00 2001 From: Teemu R Date: Tue, 26 Mar 2024 19:33:10 +0100 Subject: [PATCH] Add colortemp feature for iot devices (#827) Make color temperature feature available for iot bulbs. --- kasa/iot/iotbulb.py | 13 +++++++++++++ kasa/tests/test_bulb.py | 5 ----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/kasa/iot/iotbulb.py b/kasa/iot/iotbulb.py index 7652a1fb..1ba94300 100644 --- a/kasa/iot/iotbulb.py +++ b/kasa/iot/iotbulb.py @@ -221,6 +221,19 @@ class IotBulb(IotDevice, Bulb): ) ) + if self.is_variable_color_temp: + self._add_feature( + Feature( + device=self, + name="Color temperature", + container=self, + attribute_getter="color_temp", + attribute_setter="set_color_temp", + range_getter="valid_temperature_range", + ) + ) + + @property # type: ignore @requires_update def is_color(self) -> bool: diff --git a/kasa/tests/test_bulb.py b/kasa/tests/test_bulb.py index 2ef52fec..be27df1b 100644 --- a/kasa/tests/test_bulb.py +++ b/kasa/tests/test_bulb.py @@ -133,11 +133,6 @@ async def test_variable_temp_state_information(dev: Bulb): assert "Color temperature" in dev.state_information assert dev.state_information["Color temperature"] == dev.color_temp - assert "Valid temperature range" in dev.state_information - assert ( - dev.state_information["Valid temperature range"] == dev.valid_temperature_range - ) - @variable_temp @turn_on