Adapt group to color temperature in K (#79719)
* Adapt group to color temperature in K * Adjust tests * Adjust tests
This commit is contained in:
parent
1e5908d3a8
commit
2ee6ea9877
4 changed files with 41 additions and 38 deletions
|
@ -13,12 +13,13 @@ from homeassistant.components.light import (
|
|||
ATTR_COLOR_MODE,
|
||||
ATTR_COLOR_NAME,
|
||||
ATTR_COLOR_TEMP,
|
||||
ATTR_COLOR_TEMP_KELVIN,
|
||||
ATTR_EFFECT,
|
||||
ATTR_EFFECT_LIST,
|
||||
ATTR_FLASH,
|
||||
ATTR_HS_COLOR,
|
||||
ATTR_MAX_MIREDS,
|
||||
ATTR_MIN_MIREDS,
|
||||
ATTR_MAX_COLOR_TEMP_KELVIN,
|
||||
ATTR_MIN_COLOR_TEMP_KELVIN,
|
||||
ATTR_RGB_COLOR,
|
||||
ATTR_RGBW_COLOR,
|
||||
ATTR_RGBWW_COLOR,
|
||||
|
@ -76,7 +77,7 @@ async def test_default_state(hass):
|
|||
assert state.attributes.get(ATTR_ENTITY_ID) == ["light.kitchen", "light.bedroom"]
|
||||
assert state.attributes.get(ATTR_BRIGHTNESS) is None
|
||||
assert state.attributes.get(ATTR_HS_COLOR) is None
|
||||
assert state.attributes.get(ATTR_COLOR_TEMP) is None
|
||||
assert state.attributes.get(ATTR_COLOR_TEMP_KELVIN) is None
|
||||
assert state.attributes.get(ATTR_EFFECT_LIST) is None
|
||||
assert state.attributes.get(ATTR_EFFECT) is None
|
||||
|
||||
|
@ -685,7 +686,7 @@ async def test_color_temp(hass, enable_custom_integrations):
|
|||
entity0.supported_color_modes = {ColorMode.COLOR_TEMP}
|
||||
entity0.color_mode = ColorMode.COLOR_TEMP
|
||||
entity0.brightness = 255
|
||||
entity0.color_temp = 2
|
||||
entity0.color_temp_kelvin = 2
|
||||
|
||||
entity1 = platform.ENTITIES[1]
|
||||
entity1.supported_features = SUPPORT_COLOR_TEMP
|
||||
|
@ -710,20 +711,20 @@ async def test_color_temp(hass, enable_custom_integrations):
|
|||
|
||||
state = hass.states.get("light.light_group")
|
||||
assert state.attributes[ATTR_COLOR_MODE] == "color_temp"
|
||||
assert state.attributes[ATTR_COLOR_TEMP] == 2
|
||||
assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 2
|
||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0
|
||||
assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == ["color_temp"]
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
"turn_on",
|
||||
{"entity_id": [entity1.entity_id], ATTR_COLOR_TEMP: 1000},
|
||||
{"entity_id": [entity1.entity_id], ATTR_COLOR_TEMP_KELVIN: 1000},
|
||||
blocking=True,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.light_group")
|
||||
assert state.attributes[ATTR_COLOR_MODE] == "color_temp"
|
||||
assert state.attributes[ATTR_COLOR_TEMP] == 501
|
||||
assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 501
|
||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0
|
||||
assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == ["color_temp"]
|
||||
|
||||
|
@ -736,7 +737,7 @@ async def test_color_temp(hass, enable_custom_integrations):
|
|||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.light_group")
|
||||
assert state.attributes[ATTR_COLOR_MODE] == "color_temp"
|
||||
assert state.attributes[ATTR_COLOR_TEMP] == 1000
|
||||
assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 1000
|
||||
assert state.attributes[ATTR_SUPPORTED_FEATURES] == 0
|
||||
assert state.attributes[ATTR_SUPPORTED_COLOR_MODES] == ["color_temp"]
|
||||
|
||||
|
@ -819,14 +820,14 @@ async def test_min_max_mireds(hass, enable_custom_integrations):
|
|||
entity0 = platform.ENTITIES[0]
|
||||
entity0.supported_color_modes = {ColorMode.COLOR_TEMP}
|
||||
entity0.color_mode = ColorMode.COLOR_TEMP
|
||||
entity0.color_temp = 2
|
||||
entity0.min_mireds = 2
|
||||
entity0.max_mireds = 5
|
||||
entity0.color_temp_kelvin = 2
|
||||
entity0.min_color_temp_kelvin = 2
|
||||
entity0.max_color_temp_kelvin = 5
|
||||
|
||||
entity1 = platform.ENTITIES[1]
|
||||
entity1.supported_features = SUPPORT_COLOR_TEMP
|
||||
entity1.min_mireds = 1
|
||||
entity1.max_mireds = 1234567890
|
||||
entity1.min_color_temp_kelvin = 1
|
||||
entity1.max_color_temp_kelvin = 1234567890
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -848,8 +849,8 @@ async def test_min_max_mireds(hass, enable_custom_integrations):
|
|||
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.light_group")
|
||||
assert state.attributes[ATTR_MIN_MIREDS] == 1
|
||||
assert state.attributes[ATTR_MAX_MIREDS] == 1234567890
|
||||
assert state.attributes[ATTR_MIN_COLOR_TEMP_KELVIN] == 1
|
||||
assert state.attributes[ATTR_MAX_COLOR_TEMP_KELVIN] == 1234567890
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
|
@ -859,8 +860,8 @@ async def test_min_max_mireds(hass, enable_custom_integrations):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.light_group")
|
||||
assert state.attributes[ATTR_MIN_MIREDS] == 1
|
||||
assert state.attributes[ATTR_MAX_MIREDS] == 1234567890
|
||||
assert state.attributes[ATTR_MIN_COLOR_TEMP_KELVIN] == 1
|
||||
assert state.attributes[ATTR_MAX_COLOR_TEMP_KELVIN] == 1234567890
|
||||
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
|
@ -870,8 +871,8 @@ async def test_min_max_mireds(hass, enable_custom_integrations):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get("light.light_group")
|
||||
assert state.attributes[ATTR_MIN_MIREDS] == 1
|
||||
assert state.attributes[ATTR_MAX_MIREDS] == 1234567890
|
||||
assert state.attributes[ATTR_MIN_COLOR_TEMP_KELVIN] == 1
|
||||
assert state.attributes[ATTR_MAX_COLOR_TEMP_KELVIN] == 1234567890
|
||||
|
||||
|
||||
async def test_effect_list(hass):
|
||||
|
@ -1448,7 +1449,7 @@ async def test_invalid_service_calls(hass):
|
|||
ATTR_BRIGHTNESS: 150,
|
||||
ATTR_XY_COLOR: (0.5, 0.42),
|
||||
ATTR_RGB_COLOR: (80, 120, 50),
|
||||
ATTR_COLOR_TEMP: 1234,
|
||||
ATTR_COLOR_TEMP_KELVIN: 1234,
|
||||
ATTR_EFFECT: "Sunshine",
|
||||
ATTR_TRANSITION: 4,
|
||||
ATTR_FLASH: "long",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue