diff --git a/homeassistant/components/zha/core/const.py b/homeassistant/components/zha/core/const.py index 180be2d8830..c6958abc742 100644 --- a/homeassistant/components/zha/core/const.py +++ b/homeassistant/components/zha/core/const.py @@ -49,6 +49,7 @@ ATTR_POWER_SOURCE = "power_source" ATTR_PROFILE_ID = "profile_id" ATTR_QUIRK_APPLIED = "quirk_applied" ATTR_QUIRK_CLASS = "quirk_class" +ATTR_ROUTES = "routes" ATTR_RSSI = "rssi" ATTR_SIGNATURE = "signature" ATTR_TYPE = "type" diff --git a/homeassistant/components/zha/core/device.py b/homeassistant/components/zha/core/device.py index 5eb436cbe53..dfed1ce0ebe 100644 --- a/homeassistant/components/zha/core/device.py +++ b/homeassistant/components/zha/core/device.py @@ -57,6 +57,7 @@ from .const import ( ATTR_POWER_SOURCE, ATTR_QUIRK_APPLIED, ATTR_QUIRK_CLASS, + ATTR_ROUTES, ATTR_RSSI, ATTR_SIGNATURE, ATTR_VALUE, @@ -523,20 +524,32 @@ class ZHADevice(LogMixin): for entity_ref in self.gateway.device_registry[self.ieee] ] - # Return the neighbor information + topology = self.gateway.application_controller.topology device_info[ATTR_NEIGHBORS] = [ { - "device_type": neighbor.neighbor.device_type.name, - "rx_on_when_idle": neighbor.neighbor.rx_on_when_idle.name, - "relationship": neighbor.neighbor.relationship.name, - "extended_pan_id": str(neighbor.neighbor.extended_pan_id), - "ieee": str(neighbor.neighbor.ieee), - "nwk": str(neighbor.neighbor.nwk), - "permit_joining": neighbor.neighbor.permit_joining.name, - "depth": str(neighbor.neighbor.depth), - "lqi": str(neighbor.neighbor.lqi), + "device_type": neighbor.device_type.name, + "rx_on_when_idle": neighbor.rx_on_when_idle.name, + "relationship": neighbor.relationship.name, + "extended_pan_id": str(neighbor.extended_pan_id), + "ieee": str(neighbor.ieee), + "nwk": str(neighbor.nwk), + "permit_joining": neighbor.permit_joining.name, + "depth": str(neighbor.depth), + "lqi": str(neighbor.lqi), } - for neighbor in self._zigpy_device.neighbors + for neighbor in topology.neighbors[self.ieee] + ] + + device_info[ATTR_ROUTES] = [ + { + "dest_nwk": str(route.DstNWK), + "route_status": str(route.RouteStatus.name), + "memory_constrained": bool(route.MemoryConstrained), + "many_to_one": bool(route.ManyToOne), + "route_record_required": bool(route.RouteRecordRequired), + "next_hop": str(route.NextHop), + } + for route in topology.routes[self.ieee] ] # Return endpoint device type Names diff --git a/homeassistant/components/zha/manifest.json b/homeassistant/components/zha/manifest.json index d2b19fe8893..d617b3474f9 100644 --- a/homeassistant/components/zha/manifest.json +++ b/homeassistant/components/zha/manifest.json @@ -4,15 +4,15 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/zha", "requirements": [ - "bellows==0.34.4", + "bellows==0.34.5", "pyserial==3.5", "pyserial-asyncio==0.6", "zha-quirks==0.0.87", - "zigpy-deconz==0.19.1", - "zigpy==0.51.6", + "zigpy-deconz==0.19.2", + "zigpy==0.52.2", "zigpy-xbee==0.16.2", "zigpy-zigate==0.10.3", - "zigpy-znp==0.9.1" + "zigpy-znp==0.9.2" ], "usb": [ { diff --git a/requirements_all.txt b/requirements_all.txt index 99ef4db121f..449b5541365 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -413,7 +413,7 @@ beautifulsoup4==4.11.1 # beewi_smartclim==0.0.10 # homeassistant.components.zha -bellows==0.34.4 +bellows==0.34.5 # homeassistant.components.bmw_connected_drive bimmer_connected==0.10.4 @@ -2639,7 +2639,7 @@ zhong_hong_hvac==1.0.9 ziggo-mediabox-xl==1.1.0 # homeassistant.components.zha -zigpy-deconz==0.19.1 +zigpy-deconz==0.19.2 # homeassistant.components.zha zigpy-xbee==0.16.2 @@ -2648,10 +2648,10 @@ zigpy-xbee==0.16.2 zigpy-zigate==0.10.3 # homeassistant.components.zha -zigpy-znp==0.9.1 +zigpy-znp==0.9.2 # homeassistant.components.zha -zigpy==0.51.6 +zigpy==0.52.2 # homeassistant.components.zoneminder zm-py==0.5.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 57b4c51ac52..fbcec3f9af2 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -340,7 +340,7 @@ base36==0.1.1 beautifulsoup4==4.11.1 # homeassistant.components.zha -bellows==0.34.4 +bellows==0.34.5 # homeassistant.components.bmw_connected_drive bimmer_connected==0.10.4 @@ -1834,7 +1834,7 @@ zeroconf==0.39.4 zha-quirks==0.0.87 # homeassistant.components.zha -zigpy-deconz==0.19.1 +zigpy-deconz==0.19.2 # homeassistant.components.zha zigpy-xbee==0.16.2 @@ -1843,10 +1843,10 @@ zigpy-xbee==0.16.2 zigpy-zigate==0.10.3 # homeassistant.components.zha -zigpy-znp==0.9.1 +zigpy-znp==0.9.2 # homeassistant.components.zha -zigpy==0.51.6 +zigpy==0.52.2 # homeassistant.components.zwave_js zwave-js-server-python==0.43.0 diff --git a/tests/components/zha/conftest.py b/tests/components/zha/conftest.py index a4d29224b74..e002d8ce03b 100644 --- a/tests/components/zha/conftest.py +++ b/tests/components/zha/conftest.py @@ -57,6 +57,7 @@ def zigpy_app_controller(): type(app).nwk = PropertyMock(return_value=zigpy.types.NWK(0x0000)) type(app).devices = PropertyMock(return_value={}) type(app).backups = zigpy.backups.BackupManager(app) + type(app).topology = zigpy.topology.Topology(app) state = State() state.node_info.ieee = app.ieee.return_value