Fix WLED light transition (#30490)

pull/30493/head
Franck Nijhof 2020-01-04 22:44:28 +01:00 committed by Paulus Schoutsen
parent 049ced63b1
commit 4ea0754094
2 changed files with 8 additions and 3 deletions

View File

@ -143,8 +143,13 @@ class WLEDLight(Light, WLEDDeviceEntity):
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off the light."""
data = {ATTR_ON: False, ATTR_SEGMENT_ID: self._segment}
if ATTR_TRANSITION in kwargs:
data[ATTR_TRANSITION] = kwargs[ATTR_TRANSITION] * 1000
try:
await self.wled.light(on=False)
await self.wled.light(**data)
self._state = False
except WLEDError:
_LOGGER.error("An error occurred while turning off WLED light.")
@ -168,7 +173,7 @@ class WLEDLight(Light, WLEDDeviceEntity):
data[ATTR_COLOR_PRIMARY] = color_util.color_hsv_to_RGB(hue, sat, 100)
if ATTR_TRANSITION in kwargs:
data[ATTR_TRANSITION] = kwargs[ATTR_TRANSITION]
data[ATTR_TRANSITION] = kwargs[ATTR_TRANSITION] * 1000
if ATTR_BRIGHTNESS in kwargs:
data[ATTR_BRIGHTNESS] = kwargs[ATTR_BRIGHTNESS]

View File

@ -90,7 +90,7 @@ async def test_switch_change_state(
await hass.services.async_call(
LIGHT_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: "light.wled_rgb_light"},
{ATTR_ENTITY_ID: "light.wled_rgb_light", ATTR_TRANSITION: 5},
blocking=True,
)
await hass.async_block_till_done()