mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-30 12:34:30 +02:00
Added ip and mac detection for bonds, ref #321
This commit is contained in:
parent
332b1a6657
commit
f9edb6c1fe
1 changed files with 30 additions and 1 deletions
|
@ -234,6 +234,8 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
|
||||||
"health": {},
|
"health": {},
|
||||||
"health7": {},
|
"health7": {},
|
||||||
"interface": {},
|
"interface": {},
|
||||||
|
"bonding": {},
|
||||||
|
"bonding_slaves": {},
|
||||||
"bridge": {},
|
"bridge": {},
|
||||||
"bridge_host": {},
|
"bridge_host": {},
|
||||||
"arp": {},
|
"arp": {},
|
||||||
|
@ -824,7 +826,11 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Udpate virtual interfaces
|
# Udpate virtual interfaces
|
||||||
|
bonding = False
|
||||||
for uid, vals in self.ds["interface"].items():
|
for uid, vals in self.ds["interface"].items():
|
||||||
|
if self.ds["interface"][uid]["type"] == "bond":
|
||||||
|
bonding = True
|
||||||
|
|
||||||
self.ds["interface"][uid]["comment"] = str(
|
self.ds["interface"][uid]["comment"] = str(
|
||||||
self.ds["interface"][uid]["comment"]
|
self.ds["interface"][uid]["comment"]
|
||||||
)
|
)
|
||||||
|
@ -888,6 +894,25 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if bonding:
|
||||||
|
self.ds["bonding"] = parse_api(
|
||||||
|
data={},
|
||||||
|
source=self.api.query("/interface/bonding"),
|
||||||
|
key="name",
|
||||||
|
vals=[
|
||||||
|
{"name": "name"},
|
||||||
|
{"name": "mac-address"},
|
||||||
|
{"name": "slaves"},
|
||||||
|
{"name": "mode"},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
self.ds["bonding_slaves"] = {}
|
||||||
|
for uid, vals in self.ds["bonding"].items():
|
||||||
|
for tmp in vals["slaves"].split(","):
|
||||||
|
self.ds["bonding_slaves"][tmp] = vals
|
||||||
|
self.ds["bonding_slaves"][tmp]["master"] = uid
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_bridge
|
# get_bridge
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
@ -929,7 +954,11 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
|
||||||
self.ds["interface"][uid]["client-ip-address"] = ""
|
self.ds["interface"][uid]["client-ip-address"] = ""
|
||||||
self.ds["interface"][uid]["client-mac-address"] = ""
|
self.ds["interface"][uid]["client-mac-address"] = ""
|
||||||
for arp_uid, arp_vals in self.ds["arp"].items():
|
for arp_uid, arp_vals in self.ds["arp"].items():
|
||||||
if arp_vals["interface"] != vals["name"]:
|
if arp_vals["interface"] != vals["name"] and not (
|
||||||
|
vals["name"] in self.ds["bonding_slaves"]
|
||||||
|
and self.ds["bonding_slaves"][vals["name"]]["master"]
|
||||||
|
== arp_vals["interface"]
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self.ds["interface"][uid]["client-ip-address"] == "":
|
if self.ds["interface"][uid]["client-ip-address"] == "":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue