fixed uptime sensor #64

This commit is contained in:
tomaae 2020-12-13 02:47:03 +01:00
parent 7b137c0902
commit 77fd3889ff
2 changed files with 13 additions and 10 deletions

View file

@ -798,15 +798,18 @@ class MikrotikControllerData:
], ],
) )
# l = list(map(int, re.split('[wdhms]', self.data["resource"]["uptime_str"])[:-1])) tmp_uptime = 0
# if len(l) == 4: tmp = re.split(r"(\d+)[h]", self.data["resource"]["uptime_str"])
# self.data["resource"]["uptime"] = l[0] * 604800 + l[1] * 3600 + l[2] * 60 + l[3] if len(tmp) > 1:
# elif len(l) == 3: tmp_uptime += int(tmp[1])
# self.data["resource"]["uptime"] = l[0] * 3600 + l[1] * 60 + l[2] tmp = re.split(r"(\d+)[d]", self.data["resource"]["uptime_str"])
# elif len(l) == 2: if len(tmp) > 1:
# self.data["resource"]["uptime"] = l[0] * 60 + l[1] tmp_uptime += int(tmp[1]) * 24
# else: tmp = re.split(r"(\d+)[w]", self.data["resource"]["uptime_str"])
# self.data["resource"]["uptime"] = l[0] if len(tmp) > 1:
tmp_uptime += int(tmp[1]) * 24 * 7
self.data["resource"]["uptime"] = tmp_uptime
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(

View file

@ -49,7 +49,7 @@ SENSOR_TYPES = {
ATTR_DEVICE_CLASS: None, ATTR_DEVICE_CLASS: None,
ATTR_ICON: "mdi:clock-outline", ATTR_ICON: "mdi:clock-outline",
ATTR_LABEL: "Uptime", ATTR_LABEL: "Uptime",
ATTR_UNIT: "s", ATTR_UNIT: "h",
ATTR_GROUP: "System", ATTR_GROUP: "System",
ATTR_PATH: "resource", ATTR_PATH: "resource",
ATTR_ATTR: "uptime", ATTR_ATTR: "uptime",