mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-24 17:58:47 +02:00
Add ability to automatically determine if the LAN accounting sensor should be created depending on account-local-traffic in Mikrotik API
This commit is contained in:
parent
30c11db741
commit
f9a458bbfb
4 changed files with 44 additions and 26 deletions
|
@ -488,7 +488,7 @@ class MikrotikAPI:
|
|||
from time import time
|
||||
return int(round(time() * 1000))
|
||||
|
||||
def is_accounting_enabled(self):
|
||||
def is_accounting_enabled(self) -> bool:
|
||||
accounting = self.path("/ip/accounting", return_list=True)
|
||||
if accounting is None:
|
||||
return False
|
||||
|
@ -500,6 +500,18 @@ class MikrotikAPI:
|
|||
return True
|
||||
return False
|
||||
|
||||
def is_accounting_local_traffic_enabled(self) -> bool:
|
||||
accounting = self.path("/ip/accounting", return_list=True)
|
||||
if accounting is None:
|
||||
return False
|
||||
|
||||
for item in accounting:
|
||||
if 'account-local-traffic' not in item:
|
||||
continue
|
||||
if item['account-local-traffic']:
|
||||
return True
|
||||
return False
|
||||
|
||||
# ---------------------------
|
||||
# take_accounting_snapshot
|
||||
# Returns float -> seconds period between last run and current run
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue