Skip to content

Commit

Permalink
get interface from arp if DHCP lease server is unknown #28
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaae committed Apr 13, 2020
1 parent e55fc49 commit f5f8608
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions custom_components/mikrotik_router/mikrotik_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,13 +832,23 @@ def get_dhcp(self):
{"name": "server", "default": "unknown"},
{"name": "comment", "default": ""},
],
ensure_vals=[{"name": "interface"},],
ensure_vals=[{"name": "interface", "default": "unknown"},],
)

for uid in self.data["dhcp"]:
self.data["dhcp"][uid]["interface"] = self.data["dhcp-server"][
self.data["dhcp"][uid]["server"]
]["interface"]
if self.data["dhcp"][uid]["server"] in self.data["dhcp-server"]:
self.data["dhcp"][uid]["interface"] = self.data["dhcp-server"][
self.data["dhcp"][uid]["server"]
]["interface"]
elif uid in self.data["arp"]:
if self.data["arp"][uid]["bridge"] != "unknown":
self.data["dhcp"][uid]["interface"] = self.data["arp"][uid][
"bridge"
]
else:
self.data["dhcp"][uid]["interface"] = self.data["arp"][uid][
"interface"
]

# ---------------------------
# get_capsman_hosts
Expand Down

0 comments on commit f5f8608

Please sign in to comment.