mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
get temp and color for light during init and poll (#22847)
This commit is contained in:
parent
a40a0c4042
commit
3086e1d39d
@ -33,6 +33,10 @@ class ColorChannel(ZigbeeChannel):
|
|||||||
async def async_initialize(self, from_cache):
|
async def async_initialize(self, from_cache):
|
||||||
"""Initialize channel."""
|
"""Initialize channel."""
|
||||||
await self.fetch_color_capabilities(True)
|
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):
|
async def fetch_color_capabilities(self, from_cache):
|
||||||
"""Get the color configuration."""
|
"""Get the color configuration."""
|
||||||
|
@ -253,6 +253,20 @@ class Light(ZhaEntity, light.Light):
|
|||||||
if self._level_channel:
|
if self._level_channel:
|
||||||
self._brightness = await self._level_channel.get_attribute_value(
|
self._brightness = await self._level_channel.get_attribute_value(
|
||||||
'current_level', from_cache=from_cache)
|
'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):
|
async def refresh(self, time):
|
||||||
"""Call async_get_state at an interval."""
|
"""Call async_get_state at an interval."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user