mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-09 17:04:29 +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
|
@ -52,6 +52,7 @@ class MikrotikAPI:
|
|||
self.error = None
|
||||
self.connection_error_reported = False
|
||||
self.client_traffic_last_run = None
|
||||
self.disable_health = False
|
||||
|
||||
# Default ports
|
||||
if not self._port:
|
||||
|
@ -186,6 +187,9 @@ class MikrotikAPI:
|
|||
def query(self, path, command=None, args=None, return_list=True) -> Optional(list):
|
||||
"""Retrieve data from Mikrotik API."""
|
||||
"""Returns generator object, unless return_list passed as True"""
|
||||
if path == "/system/health" and self.disable_health:
|
||||
return None
|
||||
|
||||
if args is None:
|
||||
args = {}
|
||||
|
||||
|
@ -205,9 +209,15 @@ class MikrotikAPI:
|
|||
try:
|
||||
response = list(response)
|
||||
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.lock.release()
|
||||
return None
|
||||
|
||||
elif response and command:
|
||||
_LOGGER.debug("API query: %s, %s, %s", path, command, args)
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue