mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-09 17:04:29 +02:00
always update tracked host data from parent source #180
This commit is contained in:
parent
5bef491779
commit
0da0f876c3
1 changed files with 18 additions and 26 deletions
|
@ -1795,18 +1795,15 @@ class MikrotikControllerData:
|
||||||
if self.support_capsman:
|
if self.support_capsman:
|
||||||
for uid, vals in self.data["capsman_hosts"].items():
|
for uid, vals in self.data["capsman_hosts"].items():
|
||||||
if uid not in self.data["host"]:
|
if uid not in self.data["host"]:
|
||||||
self.data["host"][uid] = {}
|
self.data["host"][uid] = {"source": "capsman"}
|
||||||
|
elif self.data["host"][uid]["source"] != "capsman":
|
||||||
|
continue
|
||||||
|
|
||||||
self.data["host"][uid]["source"] = "capsman"
|
|
||||||
capsman_detected[uid] = True
|
capsman_detected[uid] = True
|
||||||
self.data["host"][uid]["available"] = True
|
self.data["host"][uid]["available"] = True
|
||||||
self.data["host"][uid]["last-seen"] = utcnow()
|
self.data["host"][uid]["last-seen"] = utcnow()
|
||||||
for key in ["mac-address", "interface"]:
|
for key in ["mac-address", "interface"]:
|
||||||
if (
|
self.data["host"][uid][key] = vals[key]
|
||||||
key not in self.data["host"][uid]
|
|
||||||
or self.data["host"][uid][key] == "unknown"
|
|
||||||
):
|
|
||||||
self.data["host"][uid][key] = vals[key]
|
|
||||||
|
|
||||||
# Add hosts from wireless
|
# Add hosts from wireless
|
||||||
wireless_detected = {}
|
wireless_detected = {}
|
||||||
|
@ -1816,40 +1813,35 @@ class MikrotikControllerData:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if uid not in self.data["host"]:
|
if uid not in self.data["host"]:
|
||||||
self.data["host"][uid] = {}
|
self.data["host"][uid] = {"source": "wireless"}
|
||||||
|
elif self.data["host"][uid]["source"] != "wireless":
|
||||||
|
continue
|
||||||
|
|
||||||
self.data["host"][uid]["source"] = "wireless"
|
|
||||||
wireless_detected[uid] = True
|
wireless_detected[uid] = True
|
||||||
self.data["host"][uid]["available"] = True
|
self.data["host"][uid]["available"] = True
|
||||||
self.data["host"][uid]["last-seen"] = utcnow()
|
self.data["host"][uid]["last-seen"] = utcnow()
|
||||||
for key in ["mac-address", "interface"]:
|
for key in ["mac-address", "interface"]:
|
||||||
if (
|
self.data["host"][uid][key] = vals[key]
|
||||||
key not in self.data["host"][uid]
|
|
||||||
or self.data["host"][uid][key] == "unknown"
|
|
||||||
):
|
|
||||||
self.data["host"][uid][key] = vals[key]
|
|
||||||
|
|
||||||
# Add hosts from DHCP
|
# Add hosts from DHCP
|
||||||
for uid, vals in self.data["dhcp"].items():
|
for uid, vals in self.data["dhcp"].items():
|
||||||
if uid not in self.data["host"]:
|
if uid not in self.data["host"]:
|
||||||
self.data["host"][uid] = {"source": "dhcp"}
|
self.data["host"][uid] = {"source": "dhcp"}
|
||||||
for key in ["address", "mac-address", "interface"]:
|
elif self.data["host"][uid]["source"] != "dhcp":
|
||||||
if (
|
continue
|
||||||
key not in self.data["host"][uid]
|
|
||||||
or self.data["host"][uid][key] == "unknown"
|
for key in ["address", "mac-address", "interface"]:
|
||||||
):
|
self.data["host"][uid][key] = vals[key]
|
||||||
self.data["host"][uid][key] = vals[key]
|
|
||||||
|
|
||||||
# Add hosts from ARP
|
# Add hosts from ARP
|
||||||
for uid, vals in self.data["arp"].items():
|
for uid, vals in self.data["arp"].items():
|
||||||
if uid not in self.data["host"]:
|
if uid not in self.data["host"]:
|
||||||
self.data["host"][uid] = {"source": "arp"}
|
self.data["host"][uid] = {"source": "arp"}
|
||||||
for key in ["address", "mac-address", "interface"]:
|
elif self.data["host"][uid]["source"] != "arp":
|
||||||
if (
|
continue
|
||||||
key not in self.data["host"][uid]
|
|
||||||
or self.data["host"][uid][key] == "unknown"
|
for key in ["address", "mac-address", "interface"]:
|
||||||
):
|
self.data["host"][uid][key] = vals[key]
|
||||||
self.data["host"][uid][key] = vals[key]
|
|
||||||
|
|
||||||
# Add restored hosts from hass registry
|
# Add restored hosts from hass registry
|
||||||
if not self.host_hass_recovered:
|
if not self.host_hass_recovered:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue