Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off the light."""
try:
await self.wled.light(on=False)
self._state = False
except WLEDError:
_LOGGER.error("An error occurred while turning off WLED light.")
self._available = False
self.async_schedule_update_ha_state()
async def interval_update(now: dt_util.dt.datetime = None) -> None:
"""Poll WLED device function, dispatches event after update."""
try:
await wled.update()
except WLEDError:
_LOGGER.debug("An error occurred while updating WLED", exc_info=True)
# Even if the update failed, we still send out the event.
# To allow entities to make themselves unavailable.
async_dispatcher_send(hass, DATA_WLED_UPDATED, entry.entry_id)