diff --git a/homeassistant/components/light/zha.py b/homeassistant/components/light/zha.py index 68c5bcc2a29..8eb1b3dc9b6 100644 --- a/homeassistant/components/light/zha.py +++ b/homeassistant/components/light/zha.py @@ -5,7 +5,6 @@ For more details on this platform, please refer to the documentation at https://home-assistant.io/components/light.zha/ """ import logging - from homeassistant.components import light, zha from homeassistant.const import STATE_UNKNOWN import homeassistant.util.color as color_util @@ -112,14 +111,25 @@ class Light(zha.Entity, light.Light): self._state = 1 self.async_schedule_update_ha_state() return + from zigpy.exceptions import DeliveryError + try: + await self._endpoint.on_off.on() + except DeliveryError as ex: + _LOGGER.error("Unable to turn the light on: %s", ex) + return - await self._endpoint.on_off.on() self._state = 1 self.async_schedule_update_ha_state() async def async_turn_off(self, **kwargs): """Turn the entity off.""" - await self._endpoint.on_off.off() + from zigpy.exceptions import DeliveryError + try: + await self._endpoint.on_off.off() + except DeliveryError as ex: + _LOGGER.error("Unable to turn the light off: %s", ex) + return + self._state = 0 self.async_schedule_update_ha_state() diff --git a/homeassistant/components/switch/zha.py b/homeassistant/components/switch/zha.py index 7de9f1459b1..22eb50be86b 100644 --- a/homeassistant/components/switch/zha.py +++ b/homeassistant/components/switch/zha.py @@ -57,12 +57,24 @@ class Switch(zha.Entity, SwitchDevice): async def async_turn_on(self, **kwargs): """Turn the entity on.""" - await self._endpoint.on_off.on() + from zigpy.exceptions import DeliveryError + try: + await self._endpoint.on_off.on() + except DeliveryError as ex: + _LOGGER.error("Unable to turn the switch on: %s", ex) + return + self._state = 1 async def async_turn_off(self, **kwargs): """Turn the entity off.""" - await self._endpoint.on_off.off() + from zigpy.exceptions import DeliveryError + try: + await self._endpoint.on_off.off() + except DeliveryError as ex: + _LOGGER.error("Unable to turn the switch off: %s", ex) + return + self._state = 0 async def async_update(self):