mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-08-19 08:48:50 +02:00
moved update_bridge_hosts to separate function
This commit is contained in:
parent
3b5acc2393
commit
b430acc11a
1 changed files with 40 additions and 34 deletions
|
@ -1,7 +1,5 @@
|
|||
"""Mikrotik Router integration."""
|
||||
|
||||
from .mikrotikapi import MikrotikAPI
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -19,7 +17,7 @@ from .const import (
|
|||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
from .mikrotikapi import MikrotikAPI
|
||||
#DEFAULT_SCAN_INTERVAL = timedelta(seconds=DEFAULT_SCAN_INTERVAL)
|
||||
|
||||
|
||||
|
@ -274,6 +272,19 @@ class MikrotikControllerData():
|
|||
self.data['arp'][uid]['address'] = entry['address'] if 'address' in entry else ""
|
||||
|
||||
if bridge_used:
|
||||
self.update_bridge_hosts()
|
||||
|
||||
## Map ARP to ifaces
|
||||
for uid in self.data['interface']:
|
||||
self.data['interface'][uid]['client-ip-address'] = self.data['arp'][uid]['address'] if uid in self.data['arp'] and 'address' in self.data['arp'][uid] else ""
|
||||
self.data['interface'][uid]['client-mac-address'] = self.data['arp'][uid]['mac-address'] if uid in self.data['arp'] and 'mac-address' in self.data['arp'][uid] else ""
|
||||
|
||||
return
|
||||
|
||||
#---------------------------
|
||||
# update_bridge_hosts
|
||||
#---------------------------
|
||||
def update_bridge_hosts(self):
|
||||
data = self.api.path("/interface/bridge/host")
|
||||
for entry in data:
|
||||
## Ignore port MAC
|
||||
|
@ -306,11 +317,6 @@ class MikrotikControllerData():
|
|||
if self.data['arp'][uid]['address'] == "" and self.data['arp'][uid]['mac-address'] in mac2ip:
|
||||
self.data['arp'][uid]['address'] = mac2ip[self.data['arp'][uid]['mac-address']]
|
||||
|
||||
## Map ARP to ifaces
|
||||
for uid in self.data['interface']:
|
||||
self.data['interface'][uid]['client-ip-address'] = self.data['arp'][uid]['address'] if uid in self.data['arp'] and 'address' in self.data['arp'][uid] else ""
|
||||
self.data['interface'][uid]['client-mac-address'] = self.data['arp'][uid]['mac-address'] if uid in self.data['arp'] and 'mac-address' in self.data['arp'][uid] else ""
|
||||
|
||||
return
|
||||
|
||||
#---------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue