diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index 14ebdcf..7abeddd 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -119,6 +119,12 @@ class MikrotikControllerData(): self.listeners = [] 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 # --------------------------- diff --git a/custom_components/mikrotik_router/mikrotikapi.py b/custom_components/mikrotik_router/mikrotikapi.py index f4049bb..5a7b3f9 100644 --- a/custom_components/mikrotik_router/mikrotikapi.py +++ b/custom_components/mikrotik_router/mikrotikapi.py @@ -116,3 +116,25 @@ class MikrotikAPI: return 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)