Skip to content

Commit

Permalink
Improve mapping of myuplink entities (home-assistant#129137)
Browse files Browse the repository at this point in the history
  • Loading branch information
astrandb authored Oct 29, 2024
1 parent e602a46 commit 2c89e89
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 17 deletions.
6 changes: 6 additions & 0 deletions homeassistant/components/myuplink/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
from .helpers import find_matching_platform

CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, BinarySensorEntityDescription]] = {
"F730": {
"43161": BinarySensorEntityDescription(
key="elect_add",
translation_key="elect_add",
),
},
"NIBEF": {
"43161": BinarySensorEntityDescription(
key="elect_add",
Expand Down
82 changes: 75 additions & 7 deletions homeassistant/components/myuplink/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,85 @@ def find_matching_platform(
return Platform.SENSOR


WEEKDAYS = (
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
)

PARAMETER_ID_TO_EXCLUDE_F730 = (
"40940",
"47007",
"47015",
"47020",
"47021",
"47022",
"47023",
"47024",
"47025",
"47026",
"47027",
"47028",
"47032",
"47050",
"47051",
"47206",
"47209",
"47271",
"47272",
"47273",
"47274",
"47375",
"47376",
"47538",
"47539",
"47635",
"47669",
"47703",
"47737",
"47771",
"47772",
"47805",
"47806",
"47839",
"47840",
"47907",
"47941",
"47975",
"48009",
"48042",
"48072",
"50113",
)

PARAMETER_ID_TO_INCLUDE_SMO20 = (
"40940",
"47011",
"47015",
"47028",
"47032",
"50004",
)


def skip_entity(model: str, device_point: DevicePoint) -> bool:
"""Check if entity should be skipped for this device model."""
if model == "SMO 20":
if len(device_point.smart_home_categories) > 0 or device_point.parameter_id in (
"40940",
"47011",
"47015",
"47028",
"47032",
"50004",
if (
len(device_point.smart_home_categories) > 0
or device_point.parameter_id in PARAMETER_ID_TO_INCLUDE_SMO20
):
return False
return True
if "F730" in model:
# Entity names containing weekdays are used for advanced scheduling in the
# heat pump and should not be exposed in the integration
if any(d in device_point.parameter_name.lower() for d in WEEKDAYS):
return True
if device_point.parameter_id in PARAMETER_ID_TO_EXCLUDE_F730:
return True
return False
7 changes: 7 additions & 0 deletions homeassistant/components/myuplink/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
}

CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, NumberEntityDescription]] = {
"F730": {
"40940": NumberEntityDescription(
key="degree_minutes",
translation_key="degree_minutes",
native_unit_of_measurement="DM",
),
},
"NIBEF": {
"40940": NumberEntityDescription(
key="degree_minutes",
Expand Down
26 changes: 26 additions & 0 deletions homeassistant/components/myuplink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,32 @@
MARKER_FOR_UNKNOWN_VALUE = -32768

CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, SensorEntityDescription]] = {
"F730": {
"43108": SensorEntityDescription(
key="fan_mode",
translation_key="fan_mode",
),
"43427": SensorEntityDescription(
key="status_compressor",
translation_key="status_compressor",
device_class=SensorDeviceClass.ENUM,
),
"49993": SensorEntityDescription(
key="elect_add",
translation_key="elect_add",
device_class=SensorDeviceClass.ENUM,
),
"49994": SensorEntityDescription(
key="priority",
translation_key="priority",
device_class=SensorDeviceClass.ENUM,
),
"50095": SensorEntityDescription(
key="status",
translation_key="status",
device_class=SensorDeviceClass.ENUM,
),
},
"NIBEF": {
"43108": SensorEntityDescription(
key="fan_mode",
Expand Down
5 changes: 5 additions & 0 deletions homeassistant/components/myuplink/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"alarm": {
"name": "Alarm"
}
},
"sensor": {
"status": {
"name": "Status"
}
}
}
}
10 changes: 10 additions & 0 deletions homeassistant/components/myuplink/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
from .helpers import find_matching_platform, skip_entity

CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, SwitchEntityDescription]] = {
"F730": {
"50004": SwitchEntityDescription(
key="temporary_lux",
translation_key="temporary_lux",
),
"50005": SwitchEntityDescription(
key="boost_ventilation",
translation_key="boost_ventilation",
),
},
"NIBEF": {
"50004": SwitchEntityDescription(
key="temporary_lux",
Expand Down
51 changes: 51 additions & 0 deletions tests/components/myuplink/fixtures/device_points_nibe_f730.json
Original file line number Diff line number Diff line change
Expand Up @@ -989,5 +989,56 @@
],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "147641",
"parameterName": "Start Wednesday",
"parameterUnit": "",
"writable": true,
"timestamp": "2024-10-18T09:52:01+00:00",
"value": 0,
"strVal": "0",
"smartHomeCategories": [],
"minValue": 0,
"maxValue": 86400,
"stepValue": 900,
"enumValues": [],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "148072",
"parameterName": "start diff additional heat",
"parameterUnit": "DM",
"writable": true,
"timestamp": "2024-10-18T09:51:39+00:00",
"value": 700,
"strVal": "700DM",
"smartHomeCategories": [],
"minValue": 100,
"maxValue": 2000,
"stepValue": 10,
"enumValues": [],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "47011",
"parameterName": "Heating offset climate system 1",
"parameterUnit": "",
"writable": true,
"timestamp": "2024-10-18T09:51:39+00:00",
"value": 1,
"strVal": "1",
"smartHomeCategories": ["sh-indoorSpOffsHeat"],
"minValue": -10,
"maxValue": 10,
"stepValue": 1,
"enumValues": [],
"scaleValue": "1",
"zoneId": null
}
]
102 changes: 102 additions & 0 deletions tests/components/myuplink/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,57 @@
],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "147641",
"parameterName": "Start Wednesday",
"parameterUnit": "",
"writable": true,
"timestamp": "2024-10-18T09:52:01+00:00",
"value": 0,
"strVal": "0",
"smartHomeCategories": [],
"minValue": 0,
"maxValue": 86400,
"stepValue": 900,
"enumValues": [],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "148072",
"parameterName": "start diff additional heat",
"parameterUnit": "DM",
"writable": true,
"timestamp": "2024-10-18T09:51:39+00:00",
"value": 700,
"strVal": "700DM",
"smartHomeCategories": [],
"minValue": 100,
"maxValue": 2000,
"stepValue": 10,
"enumValues": [],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "47011",
"parameterName": "Heating offset climate system 1",
"parameterUnit": "",
"writable": true,
"timestamp": "2024-10-18T09:51:39+00:00",
"value": 1,
"strVal": "1",
"smartHomeCategories": ["sh-indoorSpOffsHeat"],
"minValue": -10,
"maxValue": 10,
"stepValue": 1,
"enumValues": [],
"scaleValue": "1",
"zoneId": null
}
]

Expand Down Expand Up @@ -2093,6 +2144,57 @@
],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "147641",
"parameterName": "Start Wednesday",
"parameterUnit": "",
"writable": true,
"timestamp": "2024-10-18T09:52:01+00:00",
"value": 0,
"strVal": "0",
"smartHomeCategories": [],
"minValue": 0,
"maxValue": 86400,
"stepValue": 900,
"enumValues": [],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "148072",
"parameterName": "start diff additional heat",
"parameterUnit": "DM",
"writable": true,
"timestamp": "2024-10-18T09:51:39+00:00",
"value": 700,
"strVal": "700DM",
"smartHomeCategories": [],
"minValue": 100,
"maxValue": 2000,
"stepValue": 10,
"enumValues": [],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "47011",
"parameterName": "Heating offset climate system 1",
"parameterUnit": "",
"writable": true,
"timestamp": "2024-10-18T09:51:39+00:00",
"value": 1,
"strVal": "1",
"smartHomeCategories": ["sh-indoorSpOffsHeat"],
"minValue": -10,
"maxValue": 10,
"stepValue": 1,
"enumValues": [],
"scaleValue": "1",
"zoneId": null
}
]

Expand Down
Loading

0 comments on commit 2c89e89

Please sign in to comment.