Make sure MQTT light brightness is not rounded to 0 (#35207)
This commit is contained in:
1 parent
94b6130af6
commit
f9b420a5a5
4 files changed
+209
-12
No files matched your search
@@ -577,7 +577,8 @@ async def test_sending_rgb_color_with_brightness(hass, mqtt_mock):
|
||||
await common.async_turn_on(
|
||||
hass, "light.test", brightness=50, xy_color=[0.123, 0.123]
|
||||
)
|
||||
await common.async_turn_on(hass, "light.test", brightness=50, hs_color=[359, 78])
|
||||
await common.async_turn_on(hass, "light.test", brightness=255, hs_color=[359, 78])
|
||||
await common.async_turn_on(hass, "light.test", brightness=1)
|
||||
await common.async_turn_on(
|
||||
hass, "light.test", rgb_color=[255, 128, 0], white_value=80
|
||||
)
|
||||
@@ -597,11 +598,86 @@ async def test_sending_rgb_color_with_brightness(hass, mqtt_mock):
|
||||
"test_light_rgb/set",
|
||||
JsonValidator(
|
||||
'{"state": "ON", "color": {"r": 255, "g": 56, "b": 59},'
|
||||
' "brightness": 50}'
|
||||
' "brightness": 255}'
|
||||
),
|
||||
0,
|
||||
False,
|
||||
),
|
||||
call(
|
||||
"test_light_rgb/set",
|
||||
JsonValidator('{"state": "ON", "brightness": 1}'),
|
||||
0,
|
||||
False,
|
||||
),
|
||||
call(
|
||||
"test_light_rgb/set",
|
||||
JsonValidator(
|
||||
'{"state": "ON", "color": {"r": 255, "g": 128, "b": 0},'
|
||||
' "white_value": 80}'
|
||||
),
|
||||
0,
|
||||
False,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
async def test_sending_rgb_color_with_scaled_brightness(hass, mqtt_mock):
|
||||
"""Test light.turn_on with hs color sends rgb color parameters."""
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
light.DOMAIN,
|
||||
{
|
||||
light.DOMAIN: {
|
||||
"platform": "mqtt",
|
||||
"schema": "json",
|
||||
"name": "test",
|
||||
"command_topic": "test_light_rgb/set",
|
||||
"brightness": True,
|
||||
"brightness_scale": 100,
|
||||
"rgb": True,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
state = hass.states.get("light.test")
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
await common.async_turn_on(
|
||||
hass, "light.test", brightness=50, xy_color=[0.123, 0.123]
|
||||
)
|
||||
await common.async_turn_on(hass, "light.test", brightness=255, hs_color=[359, 78])
|
||||
await common.async_turn_on(hass, "light.test", brightness=1)
|
||||
await common.async_turn_on(
|
||||
hass, "light.test", rgb_color=[255, 128, 0], white_value=80
|
||||
)
|
||||
|
||||
mqtt_mock.async_publish.assert_has_calls(
|
||||
[
|
||||
call(
|
||||
"test_light_rgb/set",
|
||||
JsonValidator(
|
||||
'{"state": "ON", "color": {"r": 0, "g": 123, "b": 255},'
|
||||
' "brightness": 20}'
|
||||
),
|
||||
0,
|
||||
False,
|
||||
),
|
||||
call(
|
||||
"test_light_rgb/set",
|
||||
JsonValidator(
|
||||
'{"state": "ON", "color": {"r": 255, "g": 56, "b": 59},'
|
||||
' "brightness": 100}'
|
||||
),
|
||||
0,
|
||||
False,
|
||||
),
|
||||
call(
|
||||
"test_light_rgb/set",
|
||||
JsonValidator('{"state": "ON", "brightness": 1}'),
|
||||
0,
|
||||
False,
|
||||
),
|
||||
call(
|
||||
"test_light_rgb/set",
|
||||
JsonValidator(
|
||||
@@ -612,7 +688,6 @@ async def test_sending_rgb_color_with_brightness(hass, mqtt_mock):
|
||||
False,
|
||||
),
|
||||
],
|
||||
any_order=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user