Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaae committed Aug 11, 2022
1 parent 968d5c3 commit f8b8dd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 1 addition & 4 deletions custom_components/mikrotik_router/apiparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


# ---------------------------
Expand Down
9 changes: 3 additions & 6 deletions custom_components/mikrotik_router/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f8b8dd0

Please sign in to comment.