Add refoss em16 device model (#126798)

This commit is contained in:
ashionky 2024-10-25 21:22:24 +08:00 committed by GitHub
parent dab5289177
commit 92d91a65bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 3 deletions

View File

@ -20,6 +20,9 @@ COORDINATOR = "coordinator"
MAX_ERRORS = 2
# Energy monitoring
SENSOR_EM = "em"
CHANNEL_DISPLAY_NAME: dict[str, dict[int, str]] = {
"em06": {
1: "A1",
@ -28,5 +31,25 @@ CHANNEL_DISPLAY_NAME: dict[str, dict[int, str]] = {
4: "A2",
5: "B2",
6: "C2",
}
},
"em16": {
1: "A1",
2: "A2",
3: "A3",
4: "A4",
5: "A5",
6: "A6",
7: "B1",
8: "B2",
9: "B3",
10: "B4",
11: "B5",
12: "B6",
13: "C1",
14: "C2",
15: "C3",
16: "C4",
17: "C5",
18: "C6",
},
}

View File

@ -31,6 +31,7 @@ from .const import (
COORDINATORS,
DISPATCH_DEVICE_DISCOVERED,
DOMAIN,
SENSOR_EM,
)
from .entity import RefossEntity
@ -43,8 +44,13 @@ class RefossSensorEntityDescription(SensorEntityDescription):
fn: Callable[[float], float] = lambda x: x
DEVICETYPE_SENSOR: dict[str, str] = {
"em06": SENSOR_EM,
"em16": SENSOR_EM,
}
SENSORS: dict[str, tuple[RefossSensorEntityDescription, ...]] = {
"em06": (
SENSOR_EM: (
RefossSensorEntityDescription(
key="power",
translation_key="power",
@ -121,8 +127,11 @@ async def async_setup_entry(
if not isinstance(device, ElectricityXMix):
return
sensor_type = DEVICETYPE_SENSOR.get(device.device_type, "")
descriptions: tuple[RefossSensorEntityDescription, ...] = SENSORS.get(
device.device_type, ()
sensor_type, ()
)
async_add_entities(