mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-26 02:38:47 +02:00
update host ip and interface on change (dhcp/recovery) #24
This commit is contained in:
parent
fd19257b12
commit
6d2dbe8fb0
1 changed files with 11 additions and 0 deletions
|
@ -838,6 +838,17 @@ class MikrotikControllerData:
|
|||
if key not in self.data["host"][uid]:
|
||||
self.data["host"][uid][key] = default
|
||||
|
||||
# Update IP and interface (DHCP/returned host)
|
||||
if uid in self.data["dhcp"] and "." in self.data["dhcp"][uid]["address"]:
|
||||
if self.data["dhcp"][uid]["address"] != self.data["host"][uid]["address"]:
|
||||
self.data["host"][uid]["address"] = self.data["dhcp"][uid]["address"]
|
||||
self.data["host"][uid]["interface"] = self.data["dhcp"][uid]["interface"]
|
||||
|
||||
elif uid in self.data["arp"] and "." in self.data["arp"][uid]["address"] \
|
||||
and self.data["arp"][uid]["address"] != self.data["host"][uid]["address"]:
|
||||
self.data["host"][uid]["address"] = self.data["arp"][uid]["address"]
|
||||
self.data["host"][uid]["interface"] = self.data["arp"][uid]["interface"]
|
||||
|
||||
# Resolve hostname
|
||||
if vals["host-name"] == "unknown":
|
||||
if vals["address"] != "unknown":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue