From 117fec76543079f4dfa66d1e170b166d2e21f662 Mon Sep 17 00:00:00 2001 From: tomaae <23486452+tomaae@users.noreply.github.com> Date: Mon, 14 Dec 2020 15:54:32 +0100 Subject: [PATCH] Disable switch for wlans managed by caps #73 --- custom_components/mikrotik_router/mikrotik_controller.py | 1 + custom_components/mikrotik_router/switch.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index 5a47e7f..73a5707 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -536,6 +536,7 @@ class MikrotikControllerData: {"name": "link-downs"}, {"name": "tx-queue-drop"}, {"name": "actual-mtu"}, + {"name": "about", "source": ".about", "default": ""}, ], ensure_vals=[ {"name": "client-ip-address"}, diff --git a/custom_components/mikrotik_router/switch.py b/custom_components/mikrotik_router/switch.py index 89564b3..ac3200f 100644 --- a/custom_components/mikrotik_router/switch.py +++ b/custom_components/mikrotik_router/switch.py @@ -263,6 +263,9 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch): """Turn on the switch.""" path = "/interface" param = "default-name" + if self._data["about"] == "managed by CAPsMAN": + _LOGGER.error("Unable to enable %s, managed by CAPsMAN", self._data[param]) + return "managed by CAPsMAN" if "-" in self._data["port-mac-address"]: param = "name" value = self._data[param] @@ -280,6 +283,9 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch): """Turn on the switch.""" path = "/interface" param = "default-name" + if self._data["about"] == "managed by CAPsMAN": + _LOGGER.error("Unable to disable %s, managed by CAPsMAN", self._data[param]) + return "managed by CAPsMAN" if "-" in self._data["port-mac-address"]: param = "name" value = self._data[param]