From b0918fd7821e2fe57528a87be8a0a671485a0c00 Mon Sep 17 00:00:00 2001 From: tomaae <23486452+tomaae@users.noreply.github.com> Date: Wed, 8 Apr 2020 10:32:02 +0200 Subject: [PATCH] add data from arp to host --- .../mikrotik_router/mikrotik_controller.py | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index 903d3d3..04e8457 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -770,12 +770,25 @@ class MikrotikControllerData: self.data["host"][uid] = {} self.data["host"][uid]["source"] = "dhcp" - for key, key_data in zip( - ["address", "mac-address", "interface"], - ["address", "mac-address", "interface"], - ): - if key not in self.data["host"][uid] or self.data["host"][uid][key] == "unknown": - self.data["host"][uid][key] = vals[key_data] + for key, key_data in zip( + ["address", "mac-address", "interface"], + ["address", "mac-address", "interface"], + ): + if key not in self.data["host"][uid] or self.data["host"][uid][key] == "unknown": + self.data["host"][uid][key] = vals[key_data] + + # Add hosts from ARP + for uid, vals in self.data["arp"].items(): + if uid not in self.data["host"]: + self.data["host"][uid] = {} + self.data["host"][uid]["source"] = "arp" + + for key, key_data in zip( + ["address", "mac-address", "interface"], + ["address", "mac-address", "interface"], + ): + if key not in self.data["host"][uid] or self.data["host"][uid][key] == "unknown": + self.data["host"][uid][key] = vals[key_data] # Process hosts for uid, vals in self.data["host"].items(): @@ -814,3 +827,7 @@ class MikrotikControllerData: # Update last seen if self.data["host"][uid]["available"]: self.data["host"][uid]["last-seen"] = utcnow() + + # TEMP DEBUG + for uid, vals in self.data["host"].items(): + _LOGGER.warning("HOST %s: %s", uid, vals) \ No newline at end of file