Round Hue transition to steps of 100ms (#62619)
* Adding round() to transition before firing turn_on, turn_off #62608
This commit is contained in:
parent
1bbeaa722c
commit
772428e70f
6 changed files with 45 additions and 39 deletions
|
@ -110,16 +110,16 @@ async def test_light_turn_on_service(hass, mock_bridge_v2, v2_resources_test_dat
|
|||
assert test_light.attributes["color_mode"] == COLOR_MODE_COLOR_TEMP
|
||||
assert test_light.attributes["brightness"] == 255
|
||||
|
||||
# test again with sending transition
|
||||
# test again with sending transition with 250ms which should round up to 200ms
|
||||
await hass.services.async_call(
|
||||
"light",
|
||||
"turn_on",
|
||||
{"entity_id": test_light_id, "brightness_pct": 50, "transition": 6},
|
||||
{"entity_id": test_light_id, "brightness_pct": 50, "transition": 0.25},
|
||||
blocking=True,
|
||||
)
|
||||
assert len(mock_bridge_v2.mock_requests) == 2
|
||||
assert mock_bridge_v2.mock_requests[1]["json"]["on"]["on"] is True
|
||||
assert mock_bridge_v2.mock_requests[1]["json"]["dynamics"]["duration"] == 6000
|
||||
assert mock_bridge_v2.mock_requests[1]["json"]["dynamics"]["duration"] == 200
|
||||
|
||||
# test again with sending flash/alert
|
||||
await hass.services.async_call(
|
||||
|
@ -170,12 +170,12 @@ async def test_light_turn_off_service(hass, mock_bridge_v2, v2_resources_test_da
|
|||
await hass.services.async_call(
|
||||
"light",
|
||||
"turn_off",
|
||||
{"entity_id": test_light_id, "transition": 6},
|
||||
{"entity_id": test_light_id, "transition": 0.25},
|
||||
blocking=True,
|
||||
)
|
||||
assert len(mock_bridge_v2.mock_requests) == 2
|
||||
assert mock_bridge_v2.mock_requests[1]["json"]["on"]["on"] is False
|
||||
assert mock_bridge_v2.mock_requests[1]["json"]["dynamics"]["duration"] == 6000
|
||||
assert mock_bridge_v2.mock_requests[1]["json"]["dynamics"]["duration"] == 200
|
||||
|
||||
|
||||
async def test_light_added(hass, mock_bridge_v2):
|
||||
|
@ -310,7 +310,7 @@ async def test_grouped_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
"entity_id": test_light_id,
|
||||
"brightness_pct": 100,
|
||||
"xy_color": (0.123, 0.123),
|
||||
"transition": 6,
|
||||
"transition": 0.25,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
@ -325,7 +325,7 @@ async def test_grouped_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
assert mock_bridge_v2.mock_requests[index]["json"]["color"]["xy"]["x"] == 0.123
|
||||
assert mock_bridge_v2.mock_requests[index]["json"]["color"]["xy"]["y"] == 0.123
|
||||
assert (
|
||||
mock_bridge_v2.mock_requests[index]["json"]["dynamics"]["duration"] == 6000
|
||||
mock_bridge_v2.mock_requests[index]["json"]["dynamics"]["duration"] == 200
|
||||
)
|
||||
|
||||
# Now generate update events by emitting the json we've sent as incoming events
|
||||
|
@ -374,7 +374,7 @@ async def test_grouped_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
"turn_off",
|
||||
{
|
||||
"entity_id": test_light_id,
|
||||
"transition": 6,
|
||||
"transition": 0.25,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
@ -384,5 +384,5 @@ async def test_grouped_lights(hass, mock_bridge_v2, v2_resources_test_data):
|
|||
for index in range(0, 3):
|
||||
assert mock_bridge_v2.mock_requests[index]["json"]["on"]["on"] is False
|
||||
assert (
|
||||
mock_bridge_v2.mock_requests[index]["json"]["dynamics"]["duration"] == 6000
|
||||
mock_bridge_v2.mock_requests[index]["json"]["dynamics"]["duration"] == 200
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue