From bf056b6f019199a15ad0b78bf1e5439c60861d61 Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Wed, 2 May 2018 15:25:08 +0200 Subject: [PATCH] Fix Hue color state for missing xy (#14230) --- homeassistant/components/light/hue.py | 2 +- tests/components/light/test_hue.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/light/hue.py b/homeassistant/components/light/hue.py index 9f662718514..837a6f82510 100644 --- a/homeassistant/components/light/hue.py +++ b/homeassistant/components/light/hue.py @@ -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 diff --git a/tests/components/light/test_hue.py b/tests/components/light/test_hue.py index 8f5b52ea6de..a1e3867f9c3 100644 --- a/tests/components/light/test_hue.py +++ b/tests/components/light/test_hue.py @@ -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',