diff --git a/custom_components/mikrotik_router/switch.py b/custom_components/mikrotik_router/switch.py index 862281b..37a87a5 100644 --- a/custom_components/mikrotik_router/switch.py +++ b/custom_components/mikrotik_router/switch.py @@ -62,6 +62,8 @@ def update_items(inst, mikrotik_controller, async_add_entities, switches): "filter", "ppp_secret", "queue", + "kidcontrol_enable", + "kidcontrol_pause", ], # Entity function [ @@ -71,6 +73,8 @@ def update_items(inst, mikrotik_controller, async_add_entities, switches): MikrotikControllerFilterSwitch, MikrotikControllerSwitch, MikrotikControllerQueueSwitch, + MikrotikControllerSwitch, + MikrotikControllerKidcontrolPauseSwitch, ], ): uid_switch = SWITCH_TYPES[switch] @@ -551,3 +555,28 @@ class MikrotikControllerQueueSwitch(MikrotikControllerSwitch): mod_param = self.entity_description.data_switch_parameter self._ctrl.set_value(path, param, value, mod_param, True) await self._ctrl.async_update() + + +# --------------------------- +# MikrotikControllerKidcontrolPauseSwitch +# --------------------------- +class MikrotikControllerKidcontrolPauseSwitch(MikrotikControllerSwitch): + """Representation of a queue switch.""" + + async def async_turn_on(self) -> None: + """Turn on the switch.""" + path = self.entity_description.data_switch_path + param = self.entity_description.data_reference + value = self._data[self.entity_description.data_reference] + command = "resume" + self._ctrl.execute(path, command, param, value) + await self._ctrl.force_update() + + async def async_turn_off(self) -> None: + """Turn off the switch.""" + path = self.entity_description.data_switch_path + param = self.entity_description.data_reference + value = self._data[self.entity_description.data_reference] + command = "pause" + self._ctrl.execute(path, command, param, value) + await self._ctrl.async_update() diff --git a/custom_components/mikrotik_router/switch_types.py b/custom_components/mikrotik_router/switch_types.py index 1151291..9f8c9fa 100644 --- a/custom_components/mikrotik_router/switch_types.py +++ b/custom_components/mikrotik_router/switch_types.py @@ -257,4 +257,37 @@ SWITCH_TYPES = { data_reference="name", data_attributes_list=DEVICE_ATTRIBUTES_QUEUE, ), + "kidcontrol_enable": MikrotikSwitchEntityDescription( + key="kidcontrol_enable", + name="kidcontrol", + icon_enabled="mdi:account", + icon_disabled="mdi:account-off", + entity_category=None, + ha_group="Kidcontrol", + ha_connection=DOMAIN, + ha_connection_value="Kidcontrol", + data_path="kid-control", + data_switch_path="/ip/kid-control", + data_name="name", + data_uid="name", + data_reference="name", + data_attributes_list=DEVICE_ATTRIBUTES_KIDCONTROL, + ), + "kidcontrol_pause": MikrotikSwitchEntityDescription( + key="kidcontrol_paused", + name="kidcontrol paused", + icon_enabled="mdi:account-outline", + icon_disabled="mdi:account-off-outline", + entity_category=None, + ha_group="Kidcontrol", + ha_connection=DOMAIN, + ha_connection_value="Kidcontrol", + data_path="kid-control", + data_is_on="paused", + data_switch_path="/ip/kid-control", + data_name="name", + data_uid="name", + data_reference="name", + data_attributes_list=DEVICE_ATTRIBUTES_KIDCONTROL, + ), }