From c4b8c9ba5a26a95b407c206e5a149b74b2c76748 Mon Sep 17 00:00:00 2001 From: tomaae <23486452+tomaae@users.noreply.github.com> Date: Wed, 2 Dec 2020 09:29:52 +0100 Subject: [PATCH] Turn PoE on/off when switching port on/off #71 --- custom_components/mikrotik_router/switch.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/custom_components/mikrotik_router/switch.py b/custom_components/mikrotik_router/switch.py index 9ba0c2f..cd5bb76 100644 --- a/custom_components/mikrotik_router/switch.py +++ b/custom_components/mikrotik_router/switch.py @@ -269,6 +269,11 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch): mod_param = "disabled" mod_value = False self._ctrl.set_value(path, param, value, mod_param, mod_value) + + if self._data["poe-out"] == "off": + path = "/interface/ethernet" + self._ctrl.set_value(path, param, value, "poe-out", "auto-on") + await self._ctrl.force_update() async def async_turn_off(self): @@ -281,6 +286,12 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch): mod_param = "disabled" mod_value = True self._ctrl.set_value(path, param, value, mod_param, mod_value) + + + if self._data["poe-out"] == "auto-on": + path = "/interface/ethernet" + self._ctrl.set_value(path, param, value, "poe-out", "off") + await self._ctrl.async_update() # ---------------------------