Fix WLED light transition (#30490)

This commit is contained in:
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: async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off the light.""" """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: try:
await self.wled.light(on=False) await self.wled.light(**data)
self._state = False self._state = False
except WLEDError: except WLEDError:
_LOGGER.error("An error occurred while turning off WLED light.") _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) data[ATTR_COLOR_PRIMARY] = color_util.color_hsv_to_RGB(hue, sat, 100)
if ATTR_TRANSITION in kwargs: if ATTR_TRANSITION in kwargs:
data[ATTR_TRANSITION] = kwargs[ATTR_TRANSITION] data[ATTR_TRANSITION] = kwargs[ATTR_TRANSITION] * 1000
if ATTR_BRIGHTNESS in kwargs: if ATTR_BRIGHTNESS in kwargs:
data[ATTR_BRIGHTNESS] = kwargs[ATTR_BRIGHTNESS] data[ATTR_BRIGHTNESS] = kwargs[ATTR_BRIGHTNESS]

View File

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