Update new effect before calculating color on Philips TV (#52072)
This commit is contained in:
parent
8133793f23
commit
24ba81c3a2
1 changed files with 22 additions and 17 deletions
|
@ -237,29 +237,34 @@ class PhilipsTVLightEntity(CoordinatorEntity, LightEntity):
|
||||||
def _update_from_coordinator(self):
|
def _update_from_coordinator(self):
|
||||||
current = self._tv.ambilight_current_configuration
|
current = self._tv.ambilight_current_configuration
|
||||||
color = None
|
color = None
|
||||||
if current and current["isExpert"]:
|
|
||||||
if settings := _get_settings(current):
|
|
||||||
color = settings["color"]
|
|
||||||
|
|
||||||
if color:
|
|
||||||
self._attr_hs_color = (
|
|
||||||
color["hue"] * 360.0 / 255.0,
|
|
||||||
color["saturation"] * 100.0 / 255.0,
|
|
||||||
)
|
|
||||||
self._attr_brightness = color["brightness"]
|
|
||||||
elif data := self._tv.ambilight_cached:
|
|
||||||
hsv_h, hsv_s, hsv_v = color_RGB_to_hsv(*_average_pixels(data))
|
|
||||||
self._attr_hs_color = hsv_h, hsv_s
|
|
||||||
self._attr_brightness = hsv_v * 255.0 / 100.0
|
|
||||||
else:
|
|
||||||
self._attr_hs_color = None
|
|
||||||
self._attr_brightness = None
|
|
||||||
|
|
||||||
if (cache_keys := _get_cache_keys(self._tv)) != self._cache_keys:
|
if (cache_keys := _get_cache_keys(self._tv)) != self._cache_keys:
|
||||||
self._cache_keys = cache_keys
|
self._cache_keys = cache_keys
|
||||||
self._attr_effect_list = self._calculate_effect_list()
|
self._attr_effect_list = self._calculate_effect_list()
|
||||||
self._attr_effect = self._calculate_effect()
|
self._attr_effect = self._calculate_effect()
|
||||||
|
|
||||||
|
if current and current["isExpert"]:
|
||||||
|
if settings := _get_settings(current):
|
||||||
|
color = settings["color"]
|
||||||
|
|
||||||
|
mode, _, _ = _parse_effect(self._attr_effect)
|
||||||
|
|
||||||
|
if mode == EFFECT_EXPERT and color:
|
||||||
|
self._attr_hs_color = (
|
||||||
|
color["hue"] * 360.0 / 255.0,
|
||||||
|
color["saturation"] * 100.0 / 255.0,
|
||||||
|
)
|
||||||
|
self._attr_brightness = color["brightness"]
|
||||||
|
elif mode == EFFECT_MODE and self._tv.ambilight_cached:
|
||||||
|
hsv_h, hsv_s, hsv_v = color_RGB_to_hsv(
|
||||||
|
*_average_pixels(self._tv.ambilight_cached)
|
||||||
|
)
|
||||||
|
self._attr_hs_color = hsv_h, hsv_s
|
||||||
|
self._attr_brightness = hsv_v * 255.0 / 100.0
|
||||||
|
else:
|
||||||
|
self._attr_hs_color = None
|
||||||
|
self._attr_brightness = None
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self) -> None:
|
def _handle_coordinator_update(self) -> None:
|
||||||
"""Handle updated data from the coordinator."""
|
"""Handle updated data from the coordinator."""
|
||||||
|
|
Loading…
Add table
Reference in a new issue