mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-08-01 16:34:32 +02:00
redo kidcontrol switches
This commit is contained in:
parent
9a799828b0
commit
64303a3297
2 changed files with 62 additions and 0 deletions
|
@ -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()
|
||||
|
|
|
@ -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,
|
||||
),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue