From 3086e1d39d32e98957485cebf9ec8d21251fd93b Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Sun, 7 Apr 2019 22:03:38 -0400 Subject: [PATCH] get temp and color for light during init and poll (#22847) --- .../components/zha/core/channels/lighting.py | 4 ++++ homeassistant/components/zha/light.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/homeassistant/components/zha/core/channels/lighting.py b/homeassistant/components/zha/core/channels/lighting.py index 696a15b483b..c7cbdc67db9 100644 --- a/homeassistant/components/zha/core/channels/lighting.py +++ b/homeassistant/components/zha/core/channels/lighting.py @@ -33,6 +33,10 @@ class ColorChannel(ZigbeeChannel): async def async_initialize(self, from_cache): """Initialize channel.""" await self.fetch_color_capabilities(True) + await self.get_attribute_value( + 'color_temperature', from_cache=from_cache) + await self.get_attribute_value('current_x', from_cache=from_cache) + await self.get_attribute_value('current_y', from_cache=from_cache) async def fetch_color_capabilities(self, from_cache): """Get the color configuration.""" diff --git a/homeassistant/components/zha/light.py b/homeassistant/components/zha/light.py index cebc18e6a3e..eadc9e03af0 100644 --- a/homeassistant/components/zha/light.py +++ b/homeassistant/components/zha/light.py @@ -253,6 +253,20 @@ class Light(ZhaEntity, light.Light): if self._level_channel: self._brightness = await self._level_channel.get_attribute_value( 'current_level', from_cache=from_cache) + if self._color_channel: + color_capabilities = self._color_channel.get_color_capabilities() + if color_capabilities is not None and\ + color_capabilities & CAPABILITIES_COLOR_TEMP: + self._color_temp = await\ + self._color_channel.get_attribute_value( + 'color_temperature', from_cache=from_cache) + if color_capabilities is not None and\ + color_capabilities & CAPABILITIES_COLOR_XY: + color_x = await self._color_channel.get_attribute_value( + 'current_x', from_cache=from_cache) + color_y = await self._color_channel.get_attribute_value( + 'current_y', from_cache=from_cache) + self._hs_color = color_util.color_xy_to_hs(color_x, color_y) async def refresh(self, time): """Call async_get_state at an interval."""