Migrate demo lights to use Kelvin (#132837)

* Migrate demo lights to use Kelvin

* Adjust google_assistant tests
This commit is contained in:
epenet 2024-12-10 20:59:12 +01:00 committed by GitHub
parent 1b300a4389
commit fb3ffaf18d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View File

@ -7,7 +7,7 @@ from typing import Any
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_COLOR_TEMP,
ATTR_COLOR_TEMP_KELVIN,
ATTR_EFFECT,
ATTR_HS_COLOR,
ATTR_RGBW_COLOR,
@ -28,7 +28,7 @@ LIGHT_COLORS = [(56, 86), (345, 75)]
LIGHT_EFFECT_LIST = ["rainbow", "none"]
LIGHT_TEMPS = [240, 380]
LIGHT_TEMPS = [4166, 2631]
SUPPORT_DEMO = {ColorMode.HS, ColorMode.COLOR_TEMP}
SUPPORT_DEMO_HS_WHITE = {ColorMode.HS, ColorMode.WHITE}
@ -185,8 +185,8 @@ class DemoLight(LightEntity):
return self._rgbww_color
@property
def color_temp(self) -> int:
"""Return the CT color temperature."""
def color_temp_kelvin(self) -> int | None:
"""Return the color temperature value in Kelvin."""
return self._ct
@property
@ -216,9 +216,9 @@ class DemoLight(LightEntity):
if ATTR_BRIGHTNESS in kwargs:
self._brightness = kwargs[ATTR_BRIGHTNESS]
if ATTR_COLOR_TEMP in kwargs:
if ATTR_COLOR_TEMP_KELVIN in kwargs:
self._color_mode = ColorMode.COLOR_TEMP
self._ct = kwargs[ATTR_COLOR_TEMP]
self._ct = kwargs[ATTR_COLOR_TEMP_KELVIN]
if ATTR_EFFECT in kwargs:
self._effect = kwargs[ATTR_EFFECT]

View File

@ -402,7 +402,7 @@ async def test_query_message(hass: HomeAssistant) -> None:
light.async_write_ha_state()
light2 = DemoLight(
None, "Another Light", state=True, hs_color=(180, 75), ct=400, brightness=78
None, "Another Light", state=True, hs_color=(180, 75), ct=2500, brightness=78
)
light2.hass = hass
light2.entity_id = "light.another_light"
@ -410,7 +410,7 @@ async def test_query_message(hass: HomeAssistant) -> None:
light2._attr_name = "Another Light"
light2.async_write_ha_state()
light3 = DemoLight(None, "Color temp Light", state=True, ct=400, brightness=200)
light3 = DemoLight(None, "Color temp Light", state=True, ct=2500, brightness=200)
light3.hass = hass
light3.entity_id = "light.color_temp_light"
light3._attr_device_info = None