mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Adjust MQTT tests not to assert on deprecated color_temp attribute (#133198)
This commit is contained in:
parent
6ca5f3e828
commit
2003fc7ae0
@ -270,7 +270,7 @@ async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("rgbw_color") is None
|
||||
@ -285,7 +285,7 @@ async def test_no_color_brightness_color_temp_hs_white_xy_if_no_topics(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("rgbw_color") is None
|
||||
@ -350,7 +350,7 @@ async def test_controlling_state_via_topic(
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
@ -366,7 +366,7 @@ async def test_controlling_state_via_topic(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
@ -649,7 +649,7 @@ async def test_invalid_state_via_topic(
|
||||
assert state.attributes.get("rgbw_color") is None
|
||||
assert state.attributes.get("rgbww_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("xy_color") is None
|
||||
@ -665,7 +665,7 @@ async def test_invalid_state_via_topic(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") == (255, 255, 255)
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") == "none"
|
||||
assert state.attributes.get("hs_color") == (0, 0)
|
||||
assert state.attributes.get("xy_color") == (0.323, 0.329)
|
||||
@ -723,14 +723,14 @@ async def test_invalid_state_via_topic(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") == (255, 255, 251)
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_temp") == 153
|
||||
assert state.attributes.get("color_temp_kelvin") == 6535
|
||||
assert state.attributes.get("effect") == "none"
|
||||
assert state.attributes.get("hs_color") == (54.768, 1.6)
|
||||
assert state.attributes.get("xy_color") == (0.325, 0.333)
|
||||
|
||||
async_fire_mqtt_message(hass, "test_light_rgb/color_temp/status", "")
|
||||
light_state = hass.states.get("light.test")
|
||||
assert light_state.attributes["color_temp"] == 153
|
||||
assert light_state.attributes["color_temp_kelvin"] == 6535
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@ -939,7 +939,7 @@ async def test_controlling_state_via_topic_with_templates(
|
||||
hass, "test_light_rgb/color_temp/status", '{"hello": "300"}'
|
||||
)
|
||||
state = hass.states.get("light.test")
|
||||
assert state.attributes.get("color_temp") == 300
|
||||
assert state.attributes.get("color_temp_kelvin") == 3333
|
||||
assert state.attributes.get(light.ATTR_COLOR_MODE) == "color_temp"
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
@ -1160,7 +1160,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("brightness") == 60
|
||||
assert state.attributes.get("color_temp") == 125
|
||||
assert state.attributes.get("color_temp_kelvin") == 8000
|
||||
assert state.attributes.get(light.ATTR_COLOR_MODE) == "color_temp"
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
||||
@ -2103,7 +2103,7 @@ async def test_explicit_color_mode(
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
@ -2119,7 +2119,7 @@ async def test_explicit_color_mode(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
@ -2248,7 +2248,7 @@ async def test_explicit_color_mode_templated(
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get(light.ATTR_COLOR_MODE) is None
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
@ -2258,7 +2258,7 @@ async def test_explicit_color_mode_templated(
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get(light.ATTR_COLOR_MODE) == "unknown"
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
|
@ -456,7 +456,7 @@ async def test_turn_on_with_unknown_color_mode_optimistic(
|
||||
state = hass.states.get("light.test")
|
||||
assert state.attributes.get("color_mode") == light.ColorMode.UNKNOWN
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.state == STATE_ON
|
||||
|
||||
# Turn on the light with brightness or color_temp attributes
|
||||
@ -466,7 +466,7 @@ async def test_turn_on_with_unknown_color_mode_optimistic(
|
||||
state = hass.states.get("light.test")
|
||||
assert state.attributes.get("color_mode") == light.ColorMode.COLOR_TEMP
|
||||
assert state.attributes.get("brightness") == 50
|
||||
assert state.attributes.get("color_temp") == 192
|
||||
assert state.attributes.get("color_temp_kelvin") == 5208
|
||||
assert state.state == STATE_ON
|
||||
|
||||
|
||||
@ -571,7 +571,7 @@ async def test_no_color_brightness_color_temp_if_no_topics(
|
||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == expected_features
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("xy_color") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
@ -582,7 +582,7 @@ async def test_no_color_brightness_color_temp_if_no_topics(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("xy_color") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
@ -636,7 +636,7 @@ async def test_controlling_state_via_topic(
|
||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == expected_features
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("xy_color") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
@ -657,7 +657,7 @@ async def test_controlling_state_via_topic(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") == (255, 255, 255)
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_temp") is None # rgb color has priority
|
||||
assert state.attributes.get("color_temp_kelvin") is None # rgb color has priority
|
||||
assert state.attributes.get("effect") == "colorloop"
|
||||
assert state.attributes.get("xy_color") == (0.323, 0.329)
|
||||
assert state.attributes.get("hs_color") == (0.0, 0.0)
|
||||
@ -681,7 +681,7 @@ async def test_controlling_state_via_topic(
|
||||
249,
|
||||
) # temp converted to color
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_temp") == 155
|
||||
assert state.attributes.get("color_temp_kelvin") == 6451
|
||||
assert state.attributes.get("effect") == "colorloop"
|
||||
assert state.attributes.get("xy_color") == (0.328, 0.333) # temp converted to color
|
||||
assert state.attributes.get("hs_color") == (44.098, 2.43) # temp converted to color
|
||||
@ -798,7 +798,7 @@ async def test_controlling_state_via_topic2(
|
||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == expected_features
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_mode") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
@ -824,7 +824,7 @@ async def test_controlling_state_via_topic2(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_mode") == "rgbww"
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") == "colorloop"
|
||||
assert state.attributes.get("hs_color") == (20.552, 70.98)
|
||||
assert state.attributes.get("rgb_color") == (255, 136, 74)
|
||||
@ -890,7 +890,7 @@ async def test_controlling_state_via_topic2(
|
||||
)
|
||||
state = hass.states.get("light.test")
|
||||
assert state.attributes.get("color_mode") == "color_temp"
|
||||
assert state.attributes.get("color_temp") == 155
|
||||
assert state.attributes.get("color_temp_kelvin") == 6451
|
||||
|
||||
# White
|
||||
async_fire_mqtt_message(
|
||||
@ -969,7 +969,7 @@ async def test_controlling_the_state_with_legacy_color_handling(
|
||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == expected_features
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_mode") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
@ -994,7 +994,7 @@ async def test_controlling_the_state_with_legacy_color_handling(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_mode") == "hs"
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("hs_color") == (15.765, 100.0)
|
||||
assert state.attributes.get("rgb_color") == (255, 67, 0)
|
||||
@ -1016,7 +1016,7 @@ async def test_controlling_the_state_with_legacy_color_handling(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_mode") == "color_temp"
|
||||
assert state.attributes.get("color_temp") == 353
|
||||
assert state.attributes.get("color_temp_kelvin") == 2832
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("hs_color") == (28.125, 61.661)
|
||||
assert state.attributes.get("rgb_color") == (255, 171, 98)
|
||||
@ -1099,7 +1099,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("color_mode") == light.ColorMode.COLOR_TEMP
|
||||
assert state.attributes.get("color_temp") == 90
|
||||
assert state.attributes.get("color_temp_kelvin") == 11111
|
||||
|
||||
await common.async_turn_off(hass, "light.test")
|
||||
|
||||
@ -1227,7 +1227,7 @@ async def test_sending_mqtt_commands_and_optimistic2(
|
||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == expected_features
|
||||
assert state.attributes.get("brightness") == 95
|
||||
assert state.attributes.get("color_mode") == "rgb"
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") == "random"
|
||||
assert state.attributes.get("hs_color") is None
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
@ -2200,7 +2200,7 @@ async def test_invalid_values(
|
||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == expected_features
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
# Turn on the light
|
||||
@ -2218,7 +2218,7 @@ async def test_invalid_values(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") == (255, 255, 255)
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
# Empty color value
|
||||
async_fire_mqtt_message(
|
||||
hass,
|
||||
@ -2283,7 +2283,7 @@ async def test_invalid_values(
|
||||
)
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("color_temp") == 100
|
||||
assert state.attributes.get("color_temp_kelvin") == 10000
|
||||
|
||||
# Bad color temperature
|
||||
async_fire_mqtt_message(
|
||||
@ -2297,7 +2297,7 @@ async def test_invalid_values(
|
||||
# Color temperature should not have changed
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("color_temp") == 100
|
||||
assert state.attributes.get("color_temp_kelvin") == 10000
|
||||
|
||||
|
||||
@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
|
||||
|
@ -252,7 +252,7 @@ async def test_state_change_via_topic(
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
async_fire_mqtt_message(hass, "test_light_rgb", "on")
|
||||
@ -261,7 +261,7 @@ async def test_state_change_via_topic(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
|
||||
async_fire_mqtt_message(hass, "test_light_rgb", "off")
|
||||
|
||||
@ -316,7 +316,7 @@ async def test_state_brightness_color_effect_temp_change_via_topic(
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
# turn on the light
|
||||
@ -326,7 +326,7 @@ async def test_state_brightness_color_effect_temp_change_via_topic(
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("rgb_color") == (255, 128, 64)
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_temp") is None # rgb color has priority
|
||||
assert state.attributes.get("color_temp_kelvin") is None # rgb color has priority
|
||||
assert state.attributes.get("effect") is None
|
||||
|
||||
# turn on the light
|
||||
@ -340,7 +340,7 @@ async def test_state_brightness_color_effect_temp_change_via_topic(
|
||||
255,
|
||||
) # temp converted to color
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_temp") == 145
|
||||
assert state.attributes.get("color_temp_kelvin") == 6896
|
||||
assert state.attributes.get("effect") is None
|
||||
assert state.attributes.get("xy_color") == (0.317, 0.317) # temp converted to color
|
||||
assert state.attributes.get("hs_color") == (
|
||||
@ -472,7 +472,7 @@ async def test_sending_mqtt_commands_and_optimistic(
|
||||
mqtt_mock.async_publish.reset_mock()
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("color_temp") == 70
|
||||
assert state.attributes.get("color_temp_kelvin") == 14285
|
||||
|
||||
# Set full brightness
|
||||
await common.async_turn_on(hass, "light.test", brightness=255)
|
||||
@ -848,7 +848,7 @@ async def test_invalid_values(
|
||||
assert state.state == STATE_UNKNOWN
|
||||
assert state.attributes.get("rgb_color") is None
|
||||
assert state.attributes.get("brightness") is None
|
||||
assert state.attributes.get("color_temp") is None
|
||||
assert state.attributes.get("color_temp_kelvin") is None
|
||||
assert state.attributes.get("effect") is None
|
||||
assert not state.attributes.get(ATTR_ASSUMED_STATE)
|
||||
|
||||
@ -858,7 +858,7 @@ async def test_invalid_values(
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("brightness") == 255
|
||||
assert state.attributes.get("color_temp") is None # hs_color has priority
|
||||
assert state.attributes.get("color_temp_kelvin") is None # hs_color has priority
|
||||
assert state.attributes.get("rgb_color") == (255, 255, 255)
|
||||
assert state.attributes.get("effect") == "rainbow"
|
||||
|
||||
@ -887,14 +887,14 @@ async def test_invalid_values(
|
||||
async_fire_mqtt_message(hass, "test_light_rgb", "on,,215,None-None-None")
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes.get("color_temp") == 215
|
||||
assert state.attributes.get("color_temp_kelvin") == 4651
|
||||
|
||||
# bad color temp values
|
||||
async_fire_mqtt_message(hass, "test_light_rgb", "on,,off,")
|
||||
|
||||
# color temp should not have changed
|
||||
state = hass.states.get("light.test")
|
||||
assert state.attributes.get("color_temp") == 215
|
||||
assert state.attributes.get("color_temp_kelvin") == 4651
|
||||
|
||||
# bad effect value
|
||||
async_fire_mqtt_message(hass, "test_light_rgb", "on,255,a-b-c,white")
|
||||
|
Loading…
x
Reference in New Issue
Block a user