From 5a4e6bbb07795bfefffab827f8b5b380f7aac02b Mon Sep 17 00:00:00 2001 From: Alexei Chetroi Date: Sun, 23 Dec 2018 06:15:54 -0500 Subject: [PATCH] Support ZHA light turn_off transition (#19531) --- homeassistant/components/light/zha.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/light/zha.py b/homeassistant/components/light/zha.py index e6827b1bb9b..e8683e990ea 100644 --- a/homeassistant/components/light/zha.py +++ b/homeassistant/components/light/zha.py @@ -198,8 +198,15 @@ class Light(ZhaEntity, light.Light): async def async_turn_off(self, **kwargs): """Turn the entity off.""" from zigpy.exceptions import DeliveryError + duration = kwargs.get(light.ATTR_TRANSITION) try: - res = await self._endpoint.on_off.off() + supports_level = self.supported_features & light.SUPPORT_BRIGHTNESS + if duration and supports_level: + res = await self._endpoint.level.move_to_level_with_on_off( + 0, duration*10 + ) + else: + res = await self._endpoint.on_off.off() _LOGGER.debug("%s was turned off: %s", self.entity_id, res) except DeliveryError as ex: _LOGGER.error("%s: Unable to turn the light off: %s",