Fix status for Fritz device tracker (#65152)

This commit is contained in:
Simone Chemelli 2022-01-29 06:14:51 +01:00 committed by Paulus Schoutsen
parent 4ead2f2f7e
commit 84f817eb25

View File

@ -343,14 +343,15 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator):
for interf in node["node_interfaces"]: for interf in node["node_interfaces"]:
dev_mac = interf["mac_address"] dev_mac = interf["mac_address"]
if dev_mac not in hosts:
continue
dev_info: Device = hosts[dev_mac]
for link in interf["node_links"]: for link in interf["node_links"]:
intf = mesh_intf.get(link["node_interface_1_uid"]) intf = mesh_intf.get(link["node_interface_1_uid"])
if ( if intf is not None:
intf is not None
and link["state"] == "CONNECTED"
and dev_mac in hosts
):
dev_info: Device = hosts[dev_mac]
if intf["op_mode"] != "AP_GUEST": if intf["op_mode"] != "AP_GUEST":
dev_info.wan_access = not self.connection.call_action( dev_info.wan_access = not self.connection.call_action(
"X_AVM-DE_HostFilter:1", "X_AVM-DE_HostFilter:1",
@ -361,14 +362,15 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator):
dev_info.connected_to = intf["device"] dev_info.connected_to = intf["device"]
dev_info.connection_type = intf["type"] dev_info.connection_type = intf["type"]
dev_info.ssid = intf.get("ssid") dev_info.ssid = intf.get("ssid")
_LOGGER.debug("Client dev_info: %s", dev_info)
if dev_mac in self._devices: if dev_mac in self._devices:
self._devices[dev_mac].update(dev_info, consider_home) self._devices[dev_mac].update(dev_info, consider_home)
else: else:
device = FritzDevice(dev_mac, dev_info.name) device = FritzDevice(dev_mac, dev_info.name)
device.update(dev_info, consider_home) device.update(dev_info, consider_home)
self._devices[dev_mac] = device self._devices[dev_mac] = device
new_device = True new_device = True
dispatcher_send(self.hass, self.signal_device_update) dispatcher_send(self.hass, self.signal_device_update)
if new_device: if new_device: