mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-25 21:14:31 +02:00
Fix lint and tomaae's comments
This commit is contained in:
parent
d6023abc30
commit
627641b5d9
1 changed files with 11 additions and 7 deletions
|
@ -1251,16 +1251,20 @@ class MikrotikControllerData:
|
||||||
|
|
||||||
now = datetime.now().replace(microsecond=0)
|
now = datetime.now().replace(microsecond=0)
|
||||||
uptime_tm = datetime.timestamp(now - timedelta(seconds=tmp_uptime))
|
uptime_tm = datetime.timestamp(now - timedelta(seconds=tmp_uptime))
|
||||||
update_uptime = False;
|
update_uptime = False
|
||||||
if self.data["resource"]["uptime"] is None or self.data["resource"]["uptime"] == 0:
|
if not self.data["resource"]["uptime"]:
|
||||||
update_uptime = True;
|
update_uptime = True
|
||||||
else:
|
else:
|
||||||
uptime_old = datetime.timestamp(datetime.fromisoformat(self.data["resource"]["uptime"]))
|
uptime_old = datetime.timestamp(
|
||||||
if uptime_tm > uptime_old:
|
datetime.fromisoformat(self.data["resource"]["uptime"])
|
||||||
update_uptime = True;
|
)
|
||||||
|
if uptime_tm > uptime_old + 10:
|
||||||
|
update_uptime = True
|
||||||
|
|
||||||
if update_uptime:
|
if update_uptime:
|
||||||
self.data["resource"]["uptime"] = str(as_local(utc_from_timestamp(uptime_tm)).isoformat())
|
self.data["resource"]["uptime"] = str(
|
||||||
|
as_local(utc_from_timestamp(uptime_tm)).isoformat()
|
||||||
|
)
|
||||||
|
|
||||||
if self.data["resource"]["total-memory"] > 0:
|
if self.data["resource"]["total-memory"] > 0:
|
||||||
self.data["resource"]["memory-usage"] = round(
|
self.data["resource"]["memory-usage"] = round(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue