mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-24 17:58:47 +02:00
added update value for mikrotik api
This commit is contained in:
parent
a4c4b344b7
commit
a3e6e5692b
2 changed files with 28 additions and 0 deletions
|
@ -119,6 +119,12 @@ class MikrotikControllerData():
|
||||||
self.listeners = []
|
self.listeners = []
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# get_interfaces
|
||||||
|
# ---------------------------
|
||||||
|
def set_value(self, path, param, value, mod_param, mod_value):
|
||||||
|
return self.api.update(path, param, value, mod_param, mod_value)
|
||||||
|
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# get_interfaces
|
# get_interfaces
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
|
|
|
@ -116,3 +116,25 @@ class MikrotikAPI:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return response if response else None
|
return response if response else None
|
||||||
|
|
||||||
|
# ---------------------------
|
||||||
|
# update
|
||||||
|
# ---------------------------
|
||||||
|
def update(self, path, param, value, mod_param, mod_value):
|
||||||
|
response = self.path(path)
|
||||||
|
if response is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
for tmp in response:
|
||||||
|
if param not in tmp:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if tmp[param] != value:
|
||||||
|
continue
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'.id': tmp['.id'],
|
||||||
|
mod_param: mod_value
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.update(**params)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue