mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-14 19:34:29 +02:00
merged get_sfp into path
This commit is contained in:
parent
8efaa72492
commit
7782503f78
2 changed files with 10 additions and 34 deletions
|
@ -786,7 +786,11 @@ class MikrotikControllerData:
|
||||||
):
|
):
|
||||||
self.data["interface"] = parse_api(
|
self.data["interface"] = parse_api(
|
||||||
data=self.data["interface"],
|
data=self.data["interface"],
|
||||||
source=self.api.get_sfp(vals[".id"]),
|
source=self.api.path(
|
||||||
|
"/interface/ethernet",
|
||||||
|
command="monitor",
|
||||||
|
args={".id": vals[".id"], "once": True},
|
||||||
|
),
|
||||||
key_search="name",
|
key_search="name",
|
||||||
vals=[
|
vals=[
|
||||||
{"name": "status", "default": "unknown"},
|
{"name": "status", "default": "unknown"},
|
||||||
|
@ -814,7 +818,11 @@ class MikrotikControllerData:
|
||||||
else:
|
else:
|
||||||
self.data["interface"] = parse_api(
|
self.data["interface"] = parse_api(
|
||||||
data=self.data["interface"],
|
data=self.data["interface"],
|
||||||
source=self.api.get_sfp(vals[".id"]),
|
source=self.api.path(
|
||||||
|
"/interface/ethernet",
|
||||||
|
command="monitor",
|
||||||
|
args={".id": vals[".id"], "once": True},
|
||||||
|
),
|
||||||
key_search="name",
|
key_search="name",
|
||||||
vals=[
|
vals=[
|
||||||
{"name": "status", "default": "unknown"},
|
{"name": "status", "default": "unknown"},
|
||||||
|
|
|
@ -344,38 +344,6 @@ class MikrotikAPI:
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# ---------------------------
|
|
||||||
# get_sfp
|
|
||||||
# ---------------------------
|
|
||||||
def get_sfp(self, interfaces) -> Optional(list):
|
|
||||||
"""Get sfp info"""
|
|
||||||
if not self.connection_check():
|
|
||||||
return None
|
|
||||||
|
|
||||||
response = self.path("/interface/ethernet", return_list=False)
|
|
||||||
if response is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
args = {".id": interfaces, "once": True}
|
|
||||||
self.lock.acquire()
|
|
||||||
try:
|
|
||||||
_LOGGER.debug("API query: %s %s", "/interface/ethernet/monitor", interfaces)
|
|
||||||
sfpinfo = response("monitor", **args)
|
|
||||||
except Exception as e:
|
|
||||||
self.disconnect("get_sfp", e)
|
|
||||||
self.lock.release()
|
|
||||||
return None
|
|
||||||
|
|
||||||
try:
|
|
||||||
sfpinfo = list(sfpinfo)
|
|
||||||
except Exception as e:
|
|
||||||
self.disconnect("get_sfp", e)
|
|
||||||
self.lock.release()
|
|
||||||
return None
|
|
||||||
|
|
||||||
self.lock.release()
|
|
||||||
return sfpinfo or None
|
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# arp_ping
|
# arp_ping
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue