mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-15 11:54:30 +02:00
Workaround for 7.17 missing /system/health in some devices, fixes #392
This commit is contained in:
parent
6905bcb6b5
commit
477c68cf55
2 changed files with 13 additions and 2 deletions
|
@ -1428,6 +1428,7 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
|
||||||
{"name": "value", "default": "unknown"},
|
{"name": "value", "default": "unknown"},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
if self.ds["health7"]:
|
||||||
for uid, vals in self.ds["health7"].items():
|
for uid, vals in self.ds["health7"].items():
|
||||||
self.ds["health"][uid] = vals["value"]
|
self.ds["health"][uid] = vals["value"]
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ class MikrotikAPI:
|
||||||
self.error = None
|
self.error = None
|
||||||
self.connection_error_reported = False
|
self.connection_error_reported = False
|
||||||
self.client_traffic_last_run = None
|
self.client_traffic_last_run = None
|
||||||
|
self.disable_health = False
|
||||||
|
|
||||||
# Default ports
|
# Default ports
|
||||||
if not self._port:
|
if not self._port:
|
||||||
|
@ -186,6 +187,9 @@ class MikrotikAPI:
|
||||||
def query(self, path, command=None, args=None, return_list=True) -> Optional(list):
|
def query(self, path, command=None, args=None, return_list=True) -> Optional(list):
|
||||||
"""Retrieve data from Mikrotik API."""
|
"""Retrieve data from Mikrotik API."""
|
||||||
"""Returns generator object, unless return_list passed as True"""
|
"""Returns generator object, unless return_list passed as True"""
|
||||||
|
if path == "/system/health" and self.disable_health:
|
||||||
|
return None
|
||||||
|
|
||||||
if args is None:
|
if args is None:
|
||||||
args = {}
|
args = {}
|
||||||
|
|
||||||
|
@ -205,9 +209,15 @@ class MikrotikAPI:
|
||||||
try:
|
try:
|
||||||
response = list(response)
|
response = list(response)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if path == "/system/health" and "no such command prefix" in str(e):
|
||||||
|
self.disable_health = True
|
||||||
|
self.lock.release()
|
||||||
|
return None
|
||||||
|
|
||||||
self.disconnect(f"building list for path {path}", e)
|
self.disconnect(f"building list for path {path}", e)
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
elif response and command:
|
elif response and command:
|
||||||
_LOGGER.debug("API query: %s, %s, %s", path, command, args)
|
_LOGGER.debug("API query: %s, %s, %s", path, command, args)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue