Fix Hue color state for missing xy (#14230)

This commit is contained in:
Anders Melchiorsen 2018-05-02 15:25:08 +02:00 committed by Paulus Schoutsen
parent 8b13658d3b
commit bf056b6f01
2 changed files with 14 additions and 1 deletions

View File

@ -245,7 +245,7 @@ class HueLight(Light):
mode = self._color_mode
source = self.light.action if self.is_group else self.light.state
if mode in ('xy', 'hs'):
if mode in ('xy', 'hs') and 'xy' in source:
return color.color_xy_to_hs(*source['xy'])
return None

View File

@ -650,6 +650,19 @@ def test_hs_color():
assert light.hs_color is None
light = hue_light.HueLight(
light=Mock(state={
'colormode': 'hs',
'hue': 1234,
'sat': 123,
}),
request_bridge_update=None,
bridge=Mock(),
is_group=False,
)
assert light.hs_color is None
light = hue_light.HueLight(
light=Mock(state={
'colormode': 'xy',