refactoring

This commit is contained in:
Tomaae 2022-08-11 17:02:46 +02:00
parent 968d5c3859
commit f8b8dd075b
No known key found for this signature in database
GPG key ID: 8360BBD8A381D1C0
2 changed files with 4 additions and 10 deletions

View file

@ -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
# ---------------------------

View file

@ -110,14 +110,11 @@ class MikrotikHostDeviceTracker(MikrotikDeviceTracker):
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: