get temp and color for light during init and poll (#22847)

This commit is contained in:
David F. Mulcahey 2019-04-07 22:03:38 -04:00 committed by Alexei Chetroi
parent a40a0c4042
commit 3086e1d39d
2 changed files with 18 additions and 0 deletions

View File

@ -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."""

View File

@ -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."""