code cleanup

This commit is contained in:
Tomaae 2022-04-06 16:20:06 +02:00
parent 82098ba235
commit d8b073dac9
No known key found for this signature in database
GPG key ID: 8360BBD8A381D1C0

View file

@ -1984,14 +1984,15 @@ class MikrotikControllerData:
) )
# Build temp accounting values dict with ip address as key # Build temp accounting values dict with ip address as key
tmp_accounting_values = {} tmp_accounting_values = {
for uid, vals in self.data["client_traffic"].items(): vals["address"]: {
tmp_accounting_values[vals["address"]] = {
"wan-tx": 0, "wan-tx": 0,
"wan-rx": 0, "wan-rx": 0,
"lan-tx": 0, "lan-tx": 0,
"lan-rx": 0, "lan-rx": 0,
} }
for uid, vals in self.data["client_traffic"].items()
}
time_diff = self.api.take_client_traffic_snapshot(True) time_diff = self.api.take_client_traffic_snapshot(True)
if time_diff: if time_diff:
@ -2010,7 +2011,7 @@ class MikrotikControllerData:
threshold = self.api.path("/ip/accounting")[0].get("threshold") threshold = self.api.path("/ip/accounting")[0].get("threshold")
entry_count = len(accounting_data) entry_count = len(accounting_data)
if entry_count is threshold: if entry_count == threshold:
_LOGGER.warning( _LOGGER.warning(
f"Accounting entries count reached the threshold of {threshold}!" f"Accounting entries count reached the threshold of {threshold}!"
" Some entries were not saved by Mikrotik so accounting calculation won't be correct." " Some entries were not saved by Mikrotik so accounting calculation won't be correct."