Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if a lightbulb has fullcolorsupport #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pyfritzhome/devicetypes/fritzhomedevicelightbulb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The light bulb device class."""

# -*- coding: utf-8 -*-

import logging
Expand All @@ -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)
Expand Down Expand Up @@ -58,6 +60,10 @@ def _update_lightbulb_from_node(self, node):
"supported_modes"
)

self.fullcolorsupport = colorcontrol_element.attrib.get(
"fullcolorsupport"
)

except ValueError:
pass

Expand Down Expand Up @@ -120,7 +126,7 @@ def set_color(self, hsv, duration=0):

def set_unmapped_color(self, hsv, duration=0):
"""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)

def get_color_temps(self):
Expand Down
2 changes: 1 addition & 1 deletion pyfritzhome/fritzhome.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def set_color(self, ain, hsv, duration=0, mapped=True):
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)

def get_color_temps(self, ain):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fritzhomedevicelightbulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading