mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-08-31 15:09:32 +02:00
Merge pull request #285 from ivanpavlina/master
Support for additional attributes on execute
This commit is contained in:
commit
4d957aec22
2 changed files with 9 additions and 4 deletions
|
@ -387,9 +387,9 @@ class MikrotikControllerData:
|
|||
# ---------------------------
|
||||
# execute
|
||||
# ---------------------------
|
||||
def execute(self, path, command, param, value):
|
||||
def execute(self, path, command, param, value, attributes=None):
|
||||
"""Change value using Mikrotik API"""
|
||||
return self.api.execute(path, command, param, value)
|
||||
return self.api.execute(path, command, param, value, attributes)
|
||||
|
||||
# ---------------------------
|
||||
# run_script
|
||||
|
@ -1544,7 +1544,9 @@ class MikrotikControllerData:
|
|||
):
|
||||
return
|
||||
|
||||
self.execute("/system/package/update", "check-for-updates", None, None)
|
||||
self.execute(
|
||||
"/system/package/update", "check-for-updates", None, None, {"duration": 10}
|
||||
)
|
||||
self.data["fw-update"] = parse_api(
|
||||
data=self.data["fw-update"],
|
||||
source=self.api.query("/system/package/update"),
|
||||
|
|
|
@ -258,7 +258,7 @@ class MikrotikAPI:
|
|||
# ---------------------------
|
||||
# execute
|
||||
# ---------------------------
|
||||
def execute(self, path, command, param, value) -> bool:
|
||||
def execute(self, path, command, param, value, attributes=None) -> bool:
|
||||
"""Execute a command"""
|
||||
entry_found = None
|
||||
params = {}
|
||||
|
@ -292,6 +292,9 @@ class MikrotikAPI:
|
|||
|
||||
params = {".id": entry_found}
|
||||
|
||||
if attributes:
|
||||
params.update(attributes)
|
||||
|
||||
self.lock.acquire()
|
||||
try:
|
||||
tuple(response(command, **params))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue