From cd412b1050434f26a22281364784f28c1592ee11 Mon Sep 17 00:00:00 2001 From: flabbamann Date: Fri, 25 Oct 2024 10:14:22 +0200 Subject: [PATCH 1/4] Add fullcolorsupport to lightbulb --- pyfritzhome/devicetypes/fritzhomedevicelightbulb.py | 8 +++++++- tests/test_fritzhomedevicelightbulb.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pyfritzhome/devicetypes/fritzhomedevicelightbulb.py b/pyfritzhome/devicetypes/fritzhomedevicelightbulb.py index 2dbe4aa..46cb9e8 100644 --- a/pyfritzhome/devicetypes/fritzhomedevicelightbulb.py +++ b/pyfritzhome/devicetypes/fritzhomedevicelightbulb.py @@ -1,4 +1,5 @@ """The light bulb device class.""" + # -*- coding: utf-8 -*- import logging @@ -20,6 +21,7 @@ class FritzhomeDeviceLightBulb(FritzhomeDeviceBase): color_temp = None color_mode = None supported_color_mode = None + fullcolorsupport = None def _update_from_node(self, node): super()._update_from_node(node) @@ -58,6 +60,10 @@ def _update_lightbulb_from_node(self, node): "supported_modes" ) + self.fullcolorsupport = colorcontrol_element.attrib.get( + "fullcolorsupport" + ) + except ValueError: pass @@ -120,7 +126,7 @@ def set_color(self, hsv, duration=0, wait=False): def set_unmapped_color(self, hsv, duration=0, wait=False): """Set unmapped HSV color (Free color selection).""" - if self.has_color: + if self.has_color and self.fullcolorsupport: self._fritz.set_color(self.ain, hsv, duration, False, wait) def get_color_temps(self): diff --git a/tests/test_fritzhomedevicelightbulb.py b/tests/test_fritzhomedevicelightbulb.py index e7ec5c6..b667b15 100644 --- a/tests/test_fritzhomedevicelightbulb.py +++ b/tests/test_fritzhomedevicelightbulb.py @@ -38,6 +38,7 @@ def test_device_init(self): assert device.state # Lightbulb is switched on assert device.color_mode == "1" assert device.supported_color_mode == "5" + assert device.fullcolorsupport assert device.hue == 358 assert device.saturation == 180 assert device.color_temp is None @@ -87,6 +88,7 @@ def test_device_init_color_temp_mode(self): assert device.state # Lightbulb is switched on assert device.color_mode == "4" assert device.supported_color_mode == "5" + assert device.fullcolorsupport assert device.hue is None assert device.saturation is None assert device.color_temp == 2800 From 29deb844032d77094cfe9c94ca14f4dc02aaccea Mon Sep 17 00:00:00 2001 From: flabbamann Date: Fri, 25 Oct 2024 10:14:54 +0200 Subject: [PATCH 2/4] Better comment on setunmappedcolor --- pyfritzhome/fritzhome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfritzhome/fritzhome.py b/pyfritzhome/fritzhome.py index 43e1b51..da1972b 100644 --- a/pyfritzhome/fritzhome.py +++ b/pyfritzhome/fritzhome.py @@ -396,7 +396,7 @@ def set_color(self, ain, hsv, duration=0, mapped=True, wait=False): if mapped: self._aha_request("setcolor", ain=ain, param=params) else: - # undocumented API method for free color selection + # available since Fritz!OS 7.39 self._aha_request("setunmappedcolor", ain=ain, param=params) wait and self.wait_device_txbusy(ain) From 7553cbe94722cb99ada610a83295ebcf637e4e94 Mon Sep 17 00:00:00 2001 From: Lars Date: Mon, 20 Jan 2025 14:48:16 +0100 Subject: [PATCH 3/4] fullcolorsupport as bool --- pyfritzhome/devicetypes/fritzhomedevicelightbulb.py | 6 +++--- tests/test_fritzhomedevicelightbulb.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyfritzhome/devicetypes/fritzhomedevicelightbulb.py b/pyfritzhome/devicetypes/fritzhomedevicelightbulb.py index 46cb9e8..6b31010 100644 --- a/pyfritzhome/devicetypes/fritzhomedevicelightbulb.py +++ b/pyfritzhome/devicetypes/fritzhomedevicelightbulb.py @@ -21,7 +21,7 @@ class FritzhomeDeviceLightBulb(FritzhomeDeviceBase): color_temp = None color_mode = None supported_color_mode = None - fullcolorsupport = None + fullcolorsupport: bool = False def _update_from_node(self, node): super()._update_from_node(node) @@ -60,8 +60,8 @@ def _update_lightbulb_from_node(self, node): "supported_modes" ) - self.fullcolorsupport = colorcontrol_element.attrib.get( - "fullcolorsupport" + self.fullcolorsupport = bool( + colorcontrol_element.attrib.get("fullcolorsupport") ) except ValueError: diff --git a/tests/test_fritzhomedevicelightbulb.py b/tests/test_fritzhomedevicelightbulb.py index b667b15..77f83cf 100644 --- a/tests/test_fritzhomedevicelightbulb.py +++ b/tests/test_fritzhomedevicelightbulb.py @@ -67,6 +67,7 @@ def test_device_init_non_color_bulb(self): device = self.fritz.get_device_by_ain("12701 0072784-1") assert device.has_lightbulb assert device.has_level + assert device.fullcolorsupport is False assert device.state # Lightbulb is switched on assert device.name == "Telekom White Dimmable Bulb" From 2ffa257e4759a9c81e3bdfeef581bbe52ceae255 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 25 Jan 2025 17:46:27 +0100 Subject: [PATCH 4/4] Change assert Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com> --- tests/test_fritzhomedevicelightbulb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fritzhomedevicelightbulb.py b/tests/test_fritzhomedevicelightbulb.py index 77f83cf..f5a4ea5 100644 --- a/tests/test_fritzhomedevicelightbulb.py +++ b/tests/test_fritzhomedevicelightbulb.py @@ -67,7 +67,7 @@ def test_device_init_non_color_bulb(self): device = self.fritz.get_device_by_ain("12701 0072784-1") assert device.has_lightbulb assert device.has_level - assert device.fullcolorsupport is False + assert not device.fullcolorsupport assert device.state # Lightbulb is switched on assert device.name == "Telekom White Dimmable Bulb"