diff --git a/homeassistant/components/zha/core/channels/base.py b/homeassistant/components/zha/core/channels/base.py index 995d109941d8d..83accc5b86c6e 100644 --- a/homeassistant/components/zha/core/channels/base.py +++ b/homeassistant/components/zha/core/channels/base.py @@ -56,7 +56,7 @@ async def wrapper(*args, **kwds): ) return result - except (zigpy.exceptions.DeliveryError, asyncio.TimeoutError) as ex: + except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex: channel.debug("command failed: %s exception: %s", command.__name__, str(ex)) return ex @@ -135,13 +135,13 @@ def async_send_signal(self, signal: str, *args: Any) -> None: async def bind(self): """Bind a zigbee cluster. - This also swallows DeliveryError exceptions that are thrown when + This also swallows ZigbeeException exceptions that are thrown when devices are unreachable. """ try: res = await self.cluster.bind() self.debug("bound '%s' cluster: %s", self.cluster.ep_attribute, res[0]) - except (zigpy.exceptions.DeliveryError, asyncio.TimeoutError) as ex: + except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex: self.debug( "Failed to bind '%s' cluster: %s", self.cluster.ep_attribute, str(ex) ) @@ -149,7 +149,7 @@ async def bind(self): async def configure_reporting(self) -> None: """Configure attribute reporting for a cluster. - This also swallows DeliveryError exceptions that are thrown when + This also swallows ZigbeeException exceptions that are thrown when devices are unreachable. """ kwargs = {} @@ -173,7 +173,7 @@ async def configure_reporting(self) -> None: reportable_change, res, ) - except (zigpy.exceptions.DeliveryError, asyncio.TimeoutError) as ex: + except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex: self.debug( "failed to set reporting for '%s' attr on '%s' cluster: %s", attr_name, @@ -263,20 +263,15 @@ async def get_attributes(self, attributes, from_cache=True): only_cache=from_cache, manufacturer=manufacturer, ) - results = { - attribute: result.get(attribute) - for attribute in attributes - if result.get(attribute) is not None - } - except (asyncio.TimeoutError, zigpy.exceptions.DeliveryError) as ex: + return result + except (asyncio.TimeoutError, zigpy.exceptions.ZigbeeException) as ex: self.debug( "failed to get attributes '%s' on '%s' cluster: %s", attributes, self.cluster.ep_attribute, str(ex), ) - results = {} - return results + return {} def log(self, level, msg, *args): """Log a message.""" diff --git a/homeassistant/components/zha/core/channels/hvac.py b/homeassistant/components/zha/core/channels/hvac.py index bd90b907d3b6c..3c58ff946b912 100644 --- a/homeassistant/components/zha/core/channels/hvac.py +++ b/homeassistant/components/zha/core/channels/hvac.py @@ -1,7 +1,7 @@ """HVAC channels module for Zigbee Home Automation.""" import logging -from zigpy.exceptions import DeliveryError +from zigpy.exceptions import ZigbeeException import zigpy.zcl.clusters.hvac as hvac from homeassistant.core import callback @@ -31,7 +31,7 @@ async def async_set_speed(self, value) -> None: try: await self.cluster.write_attributes({"fan_mode": value}) - except DeliveryError as ex: + except ZigbeeException as ex: self.error("Could not set speed: %s", ex) return diff --git a/homeassistant/components/zha/core/channels/security.py b/homeassistant/components/zha/core/channels/security.py index 914c11331162f..b2b6f74c0de3e 100644 --- a/homeassistant/components/zha/core/channels/security.py +++ b/homeassistant/components/zha/core/channels/security.py @@ -7,7 +7,7 @@ import asyncio import logging -from zigpy.exceptions import DeliveryError +from zigpy.exceptions import ZigbeeException import zigpy.zcl.clusters.security as security from homeassistant.core import callback @@ -151,7 +151,7 @@ async def async_configure(self): self._cluster.ep_attribute, res[0], ) - except DeliveryError as ex: + except ZigbeeException as ex: self.debug( "Failed to write cie_addr: %s to '%s' cluster: %s", str(ieee), diff --git a/homeassistant/components/zha/core/device.py b/homeassistant/components/zha/core/device.py index 5782ce230837f..b4947d121e4d0 100644 --- a/homeassistant/components/zha/core/device.py +++ b/homeassistant/components/zha/core/device.py @@ -511,7 +511,7 @@ async def write_zigbee_attribute( response, ) return response - except zigpy.exceptions.DeliveryError as exc: + except zigpy.exceptions.ZigbeeException as exc: self.debug( "failed to set attribute: %s %s %s %s %s", f"{ATTR_VALUE}: {value}", @@ -563,7 +563,7 @@ async def async_remove_from_group(self, group_id): """Remove this device from the provided zigbee group.""" try: await self._zigpy_device.remove_from_group(group_id) - except (zigpy.exceptions.DeliveryError, asyncio.TimeoutError) as ex: + except (zigpy.exceptions.ZigbeeException, asyncio.TimeoutError) as ex: self.debug( "Failed to remove device '%s' from group: 0x%04x ex: %s", self._zigpy_device.ieee, diff --git a/homeassistant/components/zha/fan.py b/homeassistant/components/zha/fan.py index 8a9dc2691fc90..c7a13a4f34fb8 100644 --- a/homeassistant/components/zha/fan.py +++ b/homeassistant/components/zha/fan.py @@ -3,7 +3,7 @@ import logging from typing import List -from zigpy.exceptions import DeliveryError +from zigpy.exceptions import ZigbeeException import zigpy.zcl.clusters.hvac as hvac from homeassistant.components.fan import ( @@ -177,7 +177,7 @@ async def async_set_speed(value) -> None: """Set the speed of the fan.""" try: await self._fan_channel.write_attributes({"fan_mode": value}) - except DeliveryError as ex: + except ZigbeeException as ex: self.error("Could not set speed: %s", ex) return