1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Convert color temperature to visible color in lights (#55219)

This commit is contained in:
J. Nick Koston
2021-08-25 14:56:36 -05:00
committed by GitHub
parent 59d401e7b7
commit e6e8d7eded
12 changed files with 49 additions and 24 deletions

View File

@@ -393,7 +393,7 @@ async def test_legacy_controlling_state_via_topic(hass, mqtt_mock):
async_fire_mqtt_message(hass, "test_light_rgb/rgb/status", "125,125,125")
light_state = hass.states.get("light.test")
assert light_state.attributes.get("rgb_color") is None
assert light_state.attributes.get("rgb_color") == (255, 187, 131)
assert light_state.attributes.get(light.ATTR_COLOR_MODE) == "color_temp"
assert light_state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
@@ -636,13 +636,13 @@ async def test_legacy_invalid_state_via_topic(hass, mqtt_mock, caplog):
state = hass.states.get("light.test")
assert state.state == STATE_ON
assert state.attributes.get("rgb_color") is None
assert state.attributes.get("rgb_color") == (255, 254, 250)
assert state.attributes.get("brightness") == 255
assert state.attributes.get("color_temp") == 153
assert state.attributes.get("effect") == "none"
assert state.attributes.get("hs_color") is None
assert state.attributes.get("hs_color") == (54.768, 1.6)
assert state.attributes.get("white_value") == 255
assert state.attributes.get("xy_color") is None
assert state.attributes.get("xy_color") == (0.326, 0.333)
async_fire_mqtt_message(hass, "test_light_rgb/color_temp/status", "")
assert "Ignoring empty color temp message" in caplog.text
@@ -776,12 +776,12 @@ async def test_invalid_state_via_topic(hass, mqtt_mock, caplog):
state = hass.states.get("light.test")
assert state.state == STATE_ON
assert state.attributes.get("rgb_color") is None
assert state.attributes.get("rgb_color") == (255, 254, 250)
assert state.attributes.get("brightness") == 255
assert state.attributes.get("color_temp") == 153
assert state.attributes.get("effect") == "none"
assert state.attributes.get("hs_color") is None
assert state.attributes.get("xy_color") is None
assert state.attributes.get("hs_color") == (54.768, 1.6)
assert state.attributes.get("xy_color") == (0.326, 0.333)
async_fire_mqtt_message(hass, "test_light_rgb/color_temp/status", "")
assert "Ignoring empty color temp message" in caplog.text
@@ -988,7 +988,7 @@ async def test_legacy_controlling_state_via_topic_with_templates(hass, mqtt_mock
state = hass.states.get("light.test")
assert state.state == STATE_ON
assert state.attributes.get("brightness") == 50
assert state.attributes.get("rgb_color") is None
assert state.attributes.get("rgb_color") == (255, 187, 131)
assert state.attributes.get("color_temp") == 300
assert state.attributes.get("effect") == "rainbow"
assert state.attributes.get("white_value") == 75
@@ -1260,11 +1260,11 @@ async def test_legacy_sending_mqtt_commands_and_optimistic(hass, mqtt_mock):
state = hass.states.get("light.test")
assert state.state == STATE_ON
assert state.attributes.get("rgb_color") is None
assert state.attributes.get("rgb_color") == (221, 229, 255)
assert state.attributes["brightness"] == 50
assert state.attributes.get("hs_color") is None
assert state.attributes.get("hs_color") == (224.772, 13.249)
assert state.attributes["white_value"] == 80
assert state.attributes.get("xy_color") is None
assert state.attributes.get("xy_color") == (0.296, 0.301)
assert state.attributes["color_temp"] == 125