mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-10 01:14:33 +02:00
get_arp refractoring
This commit is contained in:
parent
a6e6f4c697
commit
0a45a072e8
1 changed files with 20 additions and 22 deletions
|
@ -46,6 +46,9 @@ class MikrotikControllerData():
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# force_update
|
||||||
|
# ---------------------------
|
||||||
async def force_update(self, now=None):
|
async def force_update(self, now=None):
|
||||||
"""Periodic update."""
|
"""Periodic update."""
|
||||||
await self.async_update()
|
await self.async_update()
|
||||||
|
@ -181,12 +184,7 @@ class MikrotikControllerData():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Get iface default-name from custom name
|
# Get iface default-name from custom name
|
||||||
uid = None
|
uid = self.get_iface_name(entry)
|
||||||
for ifacename in self.data['interface']:
|
|
||||||
if self.data['interface'][ifacename]['name'] == entry['interface']:
|
|
||||||
uid = self.data['interface'][ifacename]['default-name']
|
|
||||||
break
|
|
||||||
|
|
||||||
if not uid:
|
if not uid:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -196,15 +194,8 @@ class MikrotikControllerData():
|
||||||
|
|
||||||
# Add data
|
# Add data
|
||||||
self.data['arp'][uid]['interface'] = uid
|
self.data['arp'][uid]['interface'] = uid
|
||||||
if 'mac-address' in self.data['arp'][uid]:
|
self.data['arp'][uid]['mac-address'] = "multiple" if 'mac-address' in self.data['arp'][uid] else entry['mac-address']
|
||||||
self.data['arp'][uid]['mac-address'] = "multiple"
|
self.data['arp'][uid]['address'] = "multiple" if 'address' in self.data['arp'][uid] else entry['address']
|
||||||
else:
|
|
||||||
self.data['arp'][uid]['mac-address'] = entry['mac-address'] if 'mac-address' in entry else ""
|
|
||||||
|
|
||||||
if 'address' in self.data['arp'][uid]:
|
|
||||||
self.data['arp'][uid]['address'] = "multiple"
|
|
||||||
else:
|
|
||||||
self.data['arp'][uid]['address'] = entry['address'] if 'address' in entry else ""
|
|
||||||
|
|
||||||
if bridge_used:
|
if bridge_used:
|
||||||
self.update_bridge_hosts(mac2ip)
|
self.update_bridge_hosts(mac2ip)
|
||||||
|
@ -227,12 +218,7 @@ class MikrotikControllerData():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Get iface default-name from custom name
|
# Get iface default-name from custom name
|
||||||
uid = None
|
uid = self.get_iface_name(entry)
|
||||||
for ifacename in self.data['interface']:
|
|
||||||
if self.data['interface'][ifacename]['name'] == entry['interface']:
|
|
||||||
uid = self.data['interface'][ifacename]['default-name']
|
|
||||||
break
|
|
||||||
|
|
||||||
if not uid:
|
if not uid:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -246,7 +232,7 @@ class MikrotikControllerData():
|
||||||
self.data['arp'][uid]['mac-address'] = "multiple"
|
self.data['arp'][uid]['mac-address'] = "multiple"
|
||||||
self.data['arp'][uid]['address'] = "multiple"
|
self.data['arp'][uid]['address'] = "multiple"
|
||||||
else:
|
else:
|
||||||
self.data['arp'][uid]['mac-address'] = entry['mac-address'] if 'mac-address' in entry else ""
|
self.data['arp'][uid]['mac-address'] = entry['mac-address']
|
||||||
self.data['arp'][uid]['address'] = ""
|
self.data['arp'][uid]['address'] = ""
|
||||||
|
|
||||||
if self.data['arp'][uid]['address'] == "" and self.data['arp'][uid]['mac-address'] in mac2ip:
|
if self.data['arp'][uid]['address'] == "" and self.data['arp'][uid]['mac-address'] in mac2ip:
|
||||||
|
@ -254,6 +240,18 @@ class MikrotikControllerData():
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# get_iface_name
|
||||||
|
# ---------------------------
|
||||||
|
def get_iface_name(self, entry):
|
||||||
|
uid = None
|
||||||
|
for ifacename in self.data['interface']:
|
||||||
|
if self.data['interface'][ifacename]['name'] == entry['interface']:
|
||||||
|
uid = self.data['interface'][ifacename]['default-name']
|
||||||
|
break
|
||||||
|
|
||||||
|
return uid
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_system_routerboard
|
# get_system_routerboard
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue