Skip to content

Commit

Permalink
Velbus light platform code cleanup (home-assistant#134482)
Browse files Browse the repository at this point in the history
  • Loading branch information
cereal2nd authored Jan 10, 2025
1 parent a2d9920 commit 033064f
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions homeassistant/components/velbus/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,14 @@ def is_on(self) -> bool:
@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")

0 comments on commit 033064f

Please sign in to comment.