mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-10 17:34:29 +02:00
add data from arp to host
This commit is contained in:
parent
8b9f63c7b7
commit
b0918fd782
1 changed files with 23 additions and 6 deletions
|
@ -777,6 +777,19 @@ class MikrotikControllerData:
|
||||||
if key not in self.data["host"][uid] or self.data["host"][uid][key] == "unknown":
|
if key not in self.data["host"][uid] or self.data["host"][uid][key] == "unknown":
|
||||||
self.data["host"][uid][key] = vals[key_data]
|
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
|
# Process hosts
|
||||||
for uid, vals in self.data["host"].items():
|
for uid, vals in self.data["host"].items():
|
||||||
# Add missing default values
|
# Add missing default values
|
||||||
|
@ -814,3 +827,7 @@ class MikrotikControllerData:
|
||||||
# Update last seen
|
# Update last seen
|
||||||
if self.data["host"][uid]["available"]:
|
if self.data["host"][uid]["available"]:
|
||||||
self.data["host"][uid]["last-seen"] = utcnow()
|
self.data["host"][uid]["last-seen"] = utcnow()
|
||||||
|
|
||||||
|
# TEMP DEBUG
|
||||||
|
for uid, vals in self.data["host"].items():
|
||||||
|
_LOGGER.warning("HOST %s: %s", uid, vals)
|
Loading…
Add table
Add a link
Reference in a new issue