mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 00:07:10 +00:00
Support ZHA light turn_off transition (#19531)
This commit is contained in:
parent
0776456b59
commit
5a4e6bbb07
@ -198,7 +198,14 @@ class Light(ZhaEntity, light.Light):
|
|||||||
async def async_turn_off(self, **kwargs):
|
async def async_turn_off(self, **kwargs):
|
||||||
"""Turn the entity off."""
|
"""Turn the entity off."""
|
||||||
from zigpy.exceptions import DeliveryError
|
from zigpy.exceptions import DeliveryError
|
||||||
|
duration = kwargs.get(light.ATTR_TRANSITION)
|
||||||
try:
|
try:
|
||||||
|
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()
|
res = await self._endpoint.on_off.off()
|
||||||
_LOGGER.debug("%s was turned off: %s", self.entity_id, res)
|
_LOGGER.debug("%s was turned off: %s", self.entity_id, res)
|
||||||
except DeliveryError as ex:
|
except DeliveryError as ex:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user