From d8b073dac9df624adc06ca5fc76c4b897ddba936 Mon Sep 17 00:00:00 2001 From: Tomaae <23486452+tomaae@users.noreply.github.com> Date: Wed, 6 Apr 2022 16:20:06 +0200 Subject: [PATCH] code cleanup --- custom_components/mikrotik_router/mikrotik_controller.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index e4c7809..7498ed8 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -1984,14 +1984,15 @@ class MikrotikControllerData: ) # Build temp accounting values dict with ip address as key - tmp_accounting_values = {} - for uid, vals in self.data["client_traffic"].items(): - tmp_accounting_values[vals["address"]] = { + tmp_accounting_values = { + vals["address"]: { "wan-tx": 0, "wan-rx": 0, "lan-tx": 0, "lan-rx": 0, } + for uid, vals in self.data["client_traffic"].items() + } time_diff = self.api.take_client_traffic_snapshot(True) if time_diff: @@ -2010,7 +2011,7 @@ class MikrotikControllerData: threshold = self.api.path("/ip/accounting")[0].get("threshold") entry_count = len(accounting_data) - if entry_count is threshold: + if entry_count == threshold: _LOGGER.warning( f"Accounting entries count reached the threshold of {threshold}!" " Some entries were not saved by Mikrotik so accounting calculation won't be correct."