Add a new Homematic device type with DeviceProfileRegistry registration, custom data point class, and tests. Use when the user wants to add support for a new device model.
Device-to-profile mappings are managed via DeviceProfileRegistry. Most new devices can use existing CustomDataPoint subclasses.
Register in the appropriate entity module (e.g., aiohomematic/model/custom/switch.py, climate.py):
# In aiohomematic/model/custom/switch.py (or appropriate module)
from aiohomematic.const import DataPointCategory, DeviceProfile, Parameter
from aiohomematic.model.custom.registry import DeviceProfileRegistry, ExtendedDeviceConfig
# Simple registration
DeviceProfileRegistry.register(
category=DataPointCategory.SWITCH,
models="HmIP-NEW-SWITCH", # Single model or tuple of models
data_point_class=CustomDpSwitch, # Existing or new CustomDataPoint class
profile_type=DeviceProfile.IP_SWITCH,
channels=(3,), # Channel(s) where STATE lives
)
# With extended configuration (additional data points)
DeviceProfileRegistry.register(
category=DataPointCategory.CLIMATE,
models=("HmIP-NEW-THERMO", "HmIP-NEW-THERMO-2"),
data_point_class=CustomDpIpThermostat,
profile_type=DeviceProfile.IP_THERMOSTAT,
channels=(1,),
schedule_channel_no=1,
extended=ExtendedDeviceConfig(
additional_data_points={
0: (Parameter.SOME_EXTRA_PARAM,),
},
),
)
E.g., lock + button lock:
from aiohomematic.model.custom.registry import DeviceConfig, DeviceProfileRegistry
DeviceProfileRegistry.register_multiple(
category=DataPointCategory.LOCK,
models="HmIP-NEW-LOCK",
configs=(
DeviceConfig(
data_point_class=CustomDpIpLock,
profile_type=DeviceProfile.IP_LOCK,
),
DeviceConfig(
data_point_class=CustomDpButtonLock,
profile_type=DeviceProfile.IP_BUTTON_LOCK,
channels=(0,),
),
),
)
Create calculated class in aiohomematic/model/calculated/:
"""Calculated data point."""
from __future__ import annotations
from aiohomematic.model.calculated.data_point import CalculatedDataPoint
class NewCalculation(CalculatedDataPoint):
"""Calculate derived value."""
async def calculate_value(self) -> float:
"""Calculate and return derived value."""
value1 = await self._get_source_value("PARAMETER1")
value2 = await self._get_source_value("PARAMETER2")
return value1 + value2
Add tests in tests/test_model_*.py.
See docs/developer/extension_points.md for detailed instructions and more examples.