mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Add tests mqtt light with single supported color_mode (#91811)
This commit is contained in:
@ -268,6 +268,49 @@ async def test_fail_setup_if_color_modes_invalid(
|
||||
assert error in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"hass_config",
|
||||
[
|
||||
{
|
||||
mqtt.DOMAIN: {
|
||||
light.DOMAIN: {
|
||||
"schema": "json",
|
||||
"name": "test",
|
||||
"command_topic": "test_light/set",
|
||||
"state_topic": "test_light",
|
||||
"color_mode": True,
|
||||
"supported_color_modes": "color_temp",
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
)
|
||||
async def test_single_color_mode(
|
||||
hass: HomeAssistant,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
"""Test setup with single 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",
|
||||
'{"state": "ON", "brightness": 50, "color_mode": "color_temp", "color_temp": 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