Add childprotection module (#1141)

When turned on, rotating the thermostat will not change the target
temperature.
This commit is contained in:
Teemu R.
2024-11-01 20:46:36 +01:00
committed by GitHub
parent 77b654a9aa
commit 0360107e3f
5 changed files with 102 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ from .autooff import AutoOff
from .batterysensor import BatterySensor
from .brightness import Brightness
from .childdevice import ChildDevice
from .childprotection import ChildProtection
from .cloud import Cloud
from .color import Color
from .colortemperature import ColorTemperature
@@ -40,6 +41,7 @@ __all__ = [
"HumiditySensor",
"TemperatureSensor",
"TemperatureControl",
"ChildProtection",
"ReportMode",
"AutoOff",
"Led",

View File

@@ -0,0 +1,41 @@
"""Child lock module."""
from __future__ import annotations
from ...feature import Feature
from ..smartmodule import SmartModule
class ChildProtection(SmartModule):
"""Implementation for child_protection."""
REQUIRED_COMPONENT = "child_protection"
QUERY_GETTER_NAME = "get_child_protection"
def _initialize_features(self):
"""Initialize features after the initial update."""
self._add_feature(
Feature(
device=self._device,
id="child_lock",
name="Child lock",
container=self,
attribute_getter="enabled",
attribute_setter="set_enabled",
type=Feature.Type.Switch,
category=Feature.Category.Config,
)
)
def query(self) -> dict:
"""Query to execute during the update cycle."""
return {}
@property
def enabled(self) -> bool:
"""Return True if child protection is enabled."""
return self.data["child_protection"]
async def set_enabled(self, enabled: bool) -> dict:
"""Set child protection."""
return await self.call("set_child_protection", {"enable": enabled})