mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Migrate demo lights to use Kelvin (#132837)
* Migrate demo lights to use Kelvin * Adjust google_assistant tests
This commit is contained in:
parent
1b300a4389
commit
fb3ffaf18d
@ -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]
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user