mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-08 00:14:31 +02:00
Improved interface bandwidth tracking, fixes #166
This commit is contained in:
parent
25a09498d6
commit
5d04872032
3 changed files with 43 additions and 29 deletions
|
@ -437,7 +437,7 @@ class MikrotikAPI:
|
|||
# ---------------------------
|
||||
# get_traffic
|
||||
# ---------------------------
|
||||
def get_traffic(self, interfaces) -> Optional(list):
|
||||
def get_traffic(self) -> Optional(list):
|
||||
"""Get traffic stats"""
|
||||
if not self.connection_check():
|
||||
return None
|
||||
|
@ -446,11 +446,11 @@ class MikrotikAPI:
|
|||
if response is None:
|
||||
return None
|
||||
|
||||
args = {"interface": interfaces, "once": True}
|
||||
args = {"stats": True}
|
||||
self.lock.acquire()
|
||||
try:
|
||||
_LOGGER.debug("API query: %s", "/interface/monitor-traffic")
|
||||
traffic = response("monitor-traffic", **args)
|
||||
_LOGGER.debug("API query: %s", "/interface/print stats")
|
||||
traffic = response("print", **args)
|
||||
except librouteros.exceptions.ConnectionClosed:
|
||||
self.disconnect()
|
||||
self.lock.release()
|
||||
|
@ -487,6 +487,7 @@ class MikrotikAPI:
|
|||
return None
|
||||
|
||||
self.lock.release()
|
||||
|
||||
return traffic if traffic else None
|
||||
|
||||
# ---------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue