From 14b98c7bed94d6dc317359afb364a68de6c640dc Mon Sep 17 00:00:00 2001 From: Tomaae Date: Mon, 31 Jan 2022 09:57:16 +0100 Subject: [PATCH] cleanup system/health --- .../mikrotik_router/mikrotik_controller.py | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index e9289f6..21c71cf 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -1228,19 +1228,7 @@ class MikrotikControllerData: # --------------------------- def get_system_health(self): """Get routerboard data from Mikrotik""" - if self.major_fw_version >= 7: - self.data["health7"] = parse_api( - data=self.data["health7"], - source=self.api.path("/system/health"), - key="name", - vals=[ - {"name": "value", "default": "unknown"}, - ], - ) - for uid, vals in self.data["health7"].items(): - self.data["health"][uid] = vals["value"] - - else: + if 0 < self.major_fw_version < 7: self.data["health"] = parse_api( data=self.data["health"], source=self.api.path("/system/health"), @@ -1254,6 +1242,17 @@ class MikrotikControllerData: {"name": "fan2-speed", "default": "unknown"}, ], ) + elif 0 < self.major_fw_version >= 7: + self.data["health7"] = parse_api( + data=self.data["health7"], + source=self.api.path("/system/health"), + key="name", + vals=[ + {"name": "value", "default": "unknown"}, + ], + ) + for uid, vals in self.data["health7"].items(): + self.data["health"][uid] = vals["value"] # --------------------------- # get_system_resource