diff --git a/custom_components/mikrotik_router/apiparser.py b/custom_components/mikrotik_router/apiparser.py index 785a7d3..a352da6 100644 --- a/custom_components/mikrotik_router/apiparser.py +++ b/custom_components/mikrotik_router/apiparser.py @@ -73,10 +73,7 @@ def from_entry_bool(entry, param, default=False, reverse=False) -> bool: if not isinstance(ret, bool): ret = default - if reverse: - return not ret - - return ret + return not ret if reverse else ret # --------------------------- diff --git a/custom_components/mikrotik_router/device_tracker.py b/custom_components/mikrotik_router/device_tracker.py index a0fe9b2..4920871 100644 --- a/custom_components/mikrotik_router/device_tracker.py +++ b/custom_components/mikrotik_router/device_tracker.py @@ -110,14 +110,11 @@ def is_connected(self) -> bool: if self._data["source"] in ["capsman", "wireless"]: return self._data[self.entity_description.data_attribute] - if ( + return bool( self._data["last-seen"] - and (utcnow() - self._data["last-seen"]) + and utcnow() - self._data["last-seen"] < self.option_track_network_hosts_timeout - ): - return True - - return False + ) @property def icon(self) -> str: