Fix Hue transition calculation (#61581)
This commit is contained in:
parent
8200101785
commit
4ad90b33c9
5 changed files with 11 additions and 11 deletions
|
@ -96,8 +96,8 @@ class HueSceneEntity(HueBaseEntity, SceneEntity):
|
||||||
"""Activate Hue scene."""
|
"""Activate Hue scene."""
|
||||||
transition = kwargs.get("transition")
|
transition = kwargs.get("transition")
|
||||||
if transition is not None:
|
if transition is not None:
|
||||||
# hue transition duration is in steps of 100 ms
|
# hue transition duration is in milliseconds
|
||||||
transition = int(transition * 100)
|
transition = int(transition * 1000)
|
||||||
dynamic = kwargs.get("dynamic", self.is_dynamic)
|
dynamic = kwargs.get("dynamic", self.is_dynamic)
|
||||||
await self.bridge.async_request_call(
|
await self.bridge.async_request_call(
|
||||||
self.controller.recall,
|
self.controller.recall,
|
||||||
|
|
|
@ -150,8 +150,8 @@ class GroupedHueLight(HueBaseEntity, LightEntity):
|
||||||
# Hue uses a range of [0, 100] to control brightness.
|
# Hue uses a range of [0, 100] to control brightness.
|
||||||
brightness = float((brightness / 255) * 100)
|
brightness = float((brightness / 255) * 100)
|
||||||
if transition is not None:
|
if transition is not None:
|
||||||
# hue transition duration is in steps of 100 ms
|
# hue transition duration is in milliseconds
|
||||||
transition = int(transition * 100)
|
transition = int(transition * 1000)
|
||||||
|
|
||||||
# NOTE: a grouped_light can only handle turn on/off
|
# NOTE: a grouped_light can only handle turn on/off
|
||||||
# To set other features, you'll have to control the attached lights
|
# To set other features, you'll have to control the attached lights
|
||||||
|
|
|
@ -158,8 +158,8 @@ class HueLight(HueBaseEntity, LightEntity):
|
||||||
# Hue uses a range of [0, 100] to control brightness.
|
# Hue uses a range of [0, 100] to control brightness.
|
||||||
brightness = float((brightness / 255) * 100)
|
brightness = float((brightness / 255) * 100)
|
||||||
if transition is not None:
|
if transition is not None:
|
||||||
# hue transition duration is in steps of 100 ms
|
# hue transition duration is in milliseconds
|
||||||
transition = int(transition * 100)
|
transition = int(transition * 1000)
|
||||||
|
|
||||||
await self.bridge.async_request_call(
|
await self.bridge.async_request_call(
|
||||||
self.controller.set_state,
|
self.controller.set_state,
|
||||||
|
@ -176,8 +176,8 @@ class HueLight(HueBaseEntity, LightEntity):
|
||||||
"""Turn the light off."""
|
"""Turn the light off."""
|
||||||
transition = kwargs.get(ATTR_TRANSITION)
|
transition = kwargs.get(ATTR_TRANSITION)
|
||||||
if transition is not None:
|
if transition is not None:
|
||||||
# hue transition duration is in steps of 100 ms
|
# hue transition duration is in milliseconds
|
||||||
transition = int(transition * 100)
|
transition = int(transition * 1000)
|
||||||
await self.bridge.async_request_call(
|
await self.bridge.async_request_call(
|
||||||
self.controller.set_state,
|
self.controller.set_state,
|
||||||
id=self.resource.id,
|
id=self.resource.id,
|
||||||
|
|
|
@ -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 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"]["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):
|
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 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"]["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):
|
async def test_light_added(hass, mock_bridge_v2):
|
||||||
|
|
|
@ -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 len(mock_bridge_v2.mock_requests) == 2
|
||||||
assert mock_bridge_v2.mock_requests[1]["json"]["recall"] == {
|
assert mock_bridge_v2.mock_requests[1]["json"]["recall"] == {
|
||||||
"action": "active",
|
"action": "active",
|
||||||
"duration": 600,
|
"duration": 6000,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue