Add support for contact sensor (T110) (#877)

Initial support for T110 contact sensor & T110 fixture by courtesy of @ngaertner.
This commit is contained in:
Teemu R
2024-05-07 20:58:18 +02:00
committed by GitHub
parent 7f98acd477
commit 353e84438c
10 changed files with 621 additions and 8 deletions

View File

@@ -8,6 +8,7 @@ from .childdevicemodule import ChildDeviceModule
from .cloudmodule import CloudModule
from .colormodule import ColorModule
from .colortemp import ColorTemperatureModule
from .contact import ContactSensor
from .devicemodule import DeviceModule
from .energymodule import EnergyModule
from .fanmodule import FanModule
@@ -45,5 +46,6 @@ __all__ = [
"ColorTemperatureModule",
"ColorModule",
"WaterleakSensor",
"ContactSensor",
"FrostProtectionModule",
]

View File

@@ -0,0 +1,42 @@
"""Implementation of contact sensor module."""
from __future__ import annotations
from typing import TYPE_CHECKING
from ...feature import Feature
from ..smartmodule import SmartModule
if TYPE_CHECKING:
from ..smartdevice import SmartDevice
class ContactSensor(SmartModule):
"""Implementation of contact sensor module."""
REQUIRED_COMPONENT = None # we depend on availability of key
REQUIRED_KEY_ON_PARENT = "open"
def __init__(self, device: SmartDevice, module: str):
super().__init__(device, module)
self._add_feature(
Feature(
device,
id="is_open",
name="Open",
container=self,
attribute_getter="is_open",
icon="mdi:door",
category=Feature.Category.Primary,
type=Feature.Type.BinarySensor,
)
)
def query(self) -> dict:
"""Query to execute during the update cycle."""
return {}
@property
def is_open(self):
"""Return True if the contact sensor is open."""
return self._device.sys_info["open"]