mirror of
https://github.com/home-assistant/core.git
synced 2025-08-01 03:35:09 +02:00
Add tests mqtt light with single supported color_mode (#91811)
This commit is contained in:
@@ -183,6 +183,45 @@ async def test_rgb_light(
|
||||
assert state.attributes.get(ATTR_SUPPORTED_FEATURES) == expected_features
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"hass_config",
|
||||
[
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
light.DOMAIN: {
|
||||
"schema": "template",
|
||||
"name": "test",
|
||||
"command_topic": "test_light/set",
|
||||
"command_on_template": "on,{{ brightness|d }},{{ color_temp|d }}",
|
||||
"command_off_template": "off",
|
||||
"brightness_template": "{{ value.split(',')[1] }}",
|
||||
"color_temp_template": "{{ value.split(',')[2] }}",
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
)
|
||||
async def test_single_color_mode(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
) -> None:
|
||||
"""Test the color mode when we only have one supported color_mode."""
|
||||
await mqtt_mock_entry()
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
await common.async_turn_on(hass, "light.test", brightness=50, color_temp=192)
|
||||
async_fire_mqtt_message(hass, "test_light", "on,50,192")
|
||||
color_modes = [light.ColorMode.COLOR_TEMP]
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_ON
|
||||
|
||||
assert state.attributes.get(light.ATTR_SUPPORTED_COLOR_MODES) == color_modes
|
||||
assert state.attributes.get(light.ATTR_COLOR_TEMP) == 192
|
||||
assert state.attributes.get(light.ATTR_BRIGHTNESS) == 50
|
||||
assert state.attributes.get(light.ATTR_COLOR_MODE) == color_modes[0]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"hass_config",
|
||||
[
|
||||
|
Reference in New Issue
Block a user