Velbus light platform code cleanup (#134482)

This commit is contained in:
Maikel Punie 2025-01-10 11:10:09 +01:00 committed by GitHub
parent a2d9920aa9
commit 033064f832
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -122,19 +122,14 @@ class VelbusButtonLight(VelbusEntity, LightEntity):
@api_call
async def async_turn_on(self, **kwargs: Any) -> None:
"""Instruct the Velbus light to turn on."""
if ATTR_FLASH in kwargs:
if kwargs[ATTR_FLASH] == FLASH_LONG:
attr, *args = "set_led_state", "slow"
elif kwargs[ATTR_FLASH] == FLASH_SHORT:
attr, *args = "set_led_state", "fast"
else:
attr, *args = "set_led_state", "on"
if (flash := ATTR_FLASH in kwargs) and kwargs[ATTR_FLASH] == FLASH_LONG:
await self._channel.set_led_state("slow")
elif flash and kwargs[ATTR_FLASH] == FLASH_SHORT:
await self._channel.set_led_state("fast")
else:
attr, *args = "set_led_state", "on"
await getattr(self._channel, attr)(*args)
await self._channel.set_led_state("on")
@api_call
async def async_turn_off(self, **kwargs: Any) -> None:
"""Instruct the velbus light to turn off."""
attr, *args = "set_led_state", "off"
await getattr(self._channel, attr)(*args)
await self._channel.set_led_state("off")