Fix Hue transition calculation (#61581)

This commit is contained in:
Marcel van der Veldt 2021-12-12 23:11:41 +01:00 committed by GitHub
parent 8200101785
commit 4ad90b33c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 11 deletions

View file

@ -96,8 +96,8 @@ class HueSceneEntity(HueBaseEntity, SceneEntity):
"""Activate Hue scene."""
transition = kwargs.get("transition")
if transition is not None:
# hue transition duration is in steps of 100 ms
transition = int(transition * 100)
# hue transition duration is in milliseconds
transition = int(transition * 1000)
dynamic = kwargs.get("dynamic", self.is_dynamic)
await self.bridge.async_request_call(
self.controller.recall,

View file

@ -150,8 +150,8 @@ class GroupedHueLight(HueBaseEntity, LightEntity):
# Hue uses a range of [0, 100] to control brightness.
brightness = float((brightness / 255) * 100)
if transition is not None:
# hue transition duration is in steps of 100 ms
transition = int(transition * 100)
# hue transition duration is in milliseconds
transition = int(transition * 1000)
# NOTE: a grouped_light can only handle turn on/off
# To set other features, you'll have to control the attached lights

View file

@ -158,8 +158,8 @@ class HueLight(HueBaseEntity, LightEntity):
# Hue uses a range of [0, 100] to control brightness.
brightness = float((brightness / 255) * 100)
if transition is not None:
# hue transition duration is in steps of 100 ms
transition = int(transition * 100)
# hue transition duration is in milliseconds
transition = int(transition * 1000)
await self.bridge.async_request_call(
self.controller.set_state,
@ -176,8 +176,8 @@ class HueLight(HueBaseEntity, LightEntity):
"""Turn the light off."""
transition = kwargs.get(ATTR_TRANSITION)
if transition is not None:
# hue transition duration is in steps of 100 ms
transition = int(transition * 100)
# hue transition duration is in milliseconds
transition = int(transition * 1000)
await self.bridge.async_request_call(
self.controller.set_state,
id=self.resource.id,

View file

@ -119,7 +119,7 @@ async def test_light_turn_on_service(hass, mock_bridge_v2, v2_resources_test_dat
)
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"] == 600
assert mock_bridge_v2.mock_requests[1]["json"]["dynamics"]["duration"] == 6000
async def test_light_turn_off_service(hass, mock_bridge_v2, v2_resources_test_data):
@ -164,7 +164,7 @@ async def test_light_turn_off_service(hass, mock_bridge_v2, v2_resources_test_da
)
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"] == 600
assert mock_bridge_v2.mock_requests[1]["json"]["dynamics"]["duration"] == 6000
async def test_light_added(hass, mock_bridge_v2):

View file

@ -83,7 +83,7 @@ async def test_scene_turn_on_service(hass, mock_bridge_v2, v2_resources_test_dat
assert len(mock_bridge_v2.mock_requests) == 2
assert mock_bridge_v2.mock_requests[1]["json"]["recall"] == {
"action": "active",
"duration": 600,
"duration": 6000,
}