mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Support ZHA light turn_off transition (#19531)
This commit is contained in:
parent
0776456b59
commit
5a4e6bbb07
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user