mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Improve mapping of myuplink entities (#129137)
This commit is contained in:
parent
e602a464db
commit
2c89e89c84
@ -16,6 +16,12 @@ from .entity import MyUplinkEntity, MyUplinkSystemEntity
|
|||||||
from .helpers import find_matching_platform
|
from .helpers import find_matching_platform
|
||||||
|
|
||||||
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, BinarySensorEntityDescription]] = {
|
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, BinarySensorEntityDescription]] = {
|
||||||
|
"F730": {
|
||||||
|
"43161": BinarySensorEntityDescription(
|
||||||
|
key="elect_add",
|
||||||
|
translation_key="elect_add",
|
||||||
|
),
|
||||||
|
},
|
||||||
"NIBEF": {
|
"NIBEF": {
|
||||||
"43161": BinarySensorEntityDescription(
|
"43161": BinarySensorEntityDescription(
|
||||||
key="elect_add",
|
key="elect_add",
|
||||||
|
@ -36,17 +36,85 @@ def find_matching_platform(
|
|||||||
return Platform.SENSOR
|
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:
|
def skip_entity(model: str, device_point: DevicePoint) -> bool:
|
||||||
"""Check if entity should be skipped for this device model."""
|
"""Check if entity should be skipped for this device model."""
|
||||||
if model == "SMO 20":
|
if model == "SMO 20":
|
||||||
if len(device_point.smart_home_categories) > 0 or device_point.parameter_id in (
|
if (
|
||||||
"40940",
|
len(device_point.smart_home_categories) > 0
|
||||||
"47011",
|
or device_point.parameter_id in PARAMETER_ID_TO_INCLUDE_SMO20
|
||||||
"47015",
|
|
||||||
"47028",
|
|
||||||
"47032",
|
|
||||||
"50004",
|
|
||||||
):
|
):
|
||||||
return False
|
return False
|
||||||
return True
|
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
|
return False
|
||||||
|
@ -22,6 +22,13 @@ DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, NumberEntityDescription] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, NumberEntityDescription]] = {
|
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, NumberEntityDescription]] = {
|
||||||
|
"F730": {
|
||||||
|
"40940": NumberEntityDescription(
|
||||||
|
key="degree_minutes",
|
||||||
|
translation_key="degree_minutes",
|
||||||
|
native_unit_of_measurement="DM",
|
||||||
|
),
|
||||||
|
},
|
||||||
"NIBEF": {
|
"NIBEF": {
|
||||||
"40940": NumberEntityDescription(
|
"40940": NumberEntityDescription(
|
||||||
key="degree_minutes",
|
key="degree_minutes",
|
||||||
|
@ -139,6 +139,32 @@ DEVICE_POINT_UNIT_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
|
|||||||
MARKER_FOR_UNKNOWN_VALUE = -32768
|
MARKER_FOR_UNKNOWN_VALUE = -32768
|
||||||
|
|
||||||
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, SensorEntityDescription]] = {
|
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": {
|
"NIBEF": {
|
||||||
"43108": SensorEntityDescription(
|
"43108": SensorEntityDescription(
|
||||||
key="fan_mode",
|
key="fan_mode",
|
||||||
|
@ -34,6 +34,11 @@
|
|||||||
"alarm": {
|
"alarm": {
|
||||||
"name": "Alarm"
|
"name": "Alarm"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"status": {
|
||||||
|
"name": "Status"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,16 @@ from .entity import MyUplinkEntity
|
|||||||
from .helpers import find_matching_platform, skip_entity
|
from .helpers import find_matching_platform, skip_entity
|
||||||
|
|
||||||
CATEGORY_BASED_DESCRIPTIONS: dict[str, dict[str, SwitchEntityDescription]] = {
|
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": {
|
"NIBEF": {
|
||||||
"50004": SwitchEntityDescription(
|
"50004": SwitchEntityDescription(
|
||||||
key="temporary_lux",
|
key="temporary_lux",
|
||||||
|
@ -989,5 +989,56 @@
|
|||||||
],
|
],
|
||||||
"scaleValue": "1",
|
"scaleValue": "1",
|
||||||
"zoneId": null
|
"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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1050,6 +1050,57 @@
|
|||||||
],
|
],
|
||||||
"scaleValue": "1",
|
"scaleValue": "1",
|
||||||
"zoneId": null
|
"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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2093,6 +2144,57 @@
|
|||||||
],
|
],
|
||||||
"scaleValue": "1",
|
"scaleValue": "1",
|
||||||
"zoneId": null
|
"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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ from homeassistant.helpers import entity_registry as er
|
|||||||
TEST_PLATFORM = Platform.NUMBER
|
TEST_PLATFORM = Platform.NUMBER
|
||||||
pytestmark = pytest.mark.parametrize("platforms", [(TEST_PLATFORM,)])
|
pytestmark = pytest.mark.parametrize("platforms", [(TEST_PLATFORM,)])
|
||||||
|
|
||||||
ENTITY_ID = "number.gotham_city_degree_minutes"
|
ENTITY_ID = "number.gotham_city_heating_offset_climate_system_1"
|
||||||
ENTITY_FRIENDLY_NAME = "Gotham City Degree minutes"
|
ENTITY_FRIENDLY_NAME = "Gotham City Heating offset climate system 1"
|
||||||
ENTITY_UID = "robin-r-1234-20240201-123456-aa-bb-cc-dd-ee-ff-40940"
|
ENTITY_UID = "robin-r-1234-20240201-123456-aa-bb-cc-dd-ee-ff-47011"
|
||||||
|
|
||||||
|
|
||||||
async def test_entity_registry(
|
async def test_entity_registry(
|
||||||
@ -36,17 +36,16 @@ async def test_attributes(
|
|||||||
mock_myuplink_client: MagicMock,
|
mock_myuplink_client: MagicMock,
|
||||||
setup_platform: None,
|
setup_platform: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the switch attributes are correct."""
|
"""Test the entity attributes are correct."""
|
||||||
|
|
||||||
state = hass.states.get(ENTITY_ID)
|
state = hass.states.get(ENTITY_ID)
|
||||||
assert state.state == "-875.0"
|
assert state.state == "1.0"
|
||||||
assert state.attributes == {
|
assert state.attributes == {
|
||||||
"friendly_name": ENTITY_FRIENDLY_NAME,
|
"friendly_name": ENTITY_FRIENDLY_NAME,
|
||||||
"min": -3000,
|
"min": -10.0,
|
||||||
"max": 3000,
|
"max": 10.0,
|
||||||
"mode": "auto",
|
"mode": "auto",
|
||||||
"step": 1.0,
|
"step": 1.0,
|
||||||
"unit_of_measurement": "DM",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ async def test_set_value(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
TEST_PLATFORM,
|
TEST_PLATFORM,
|
||||||
SERVICE_SET_VALUE,
|
SERVICE_SET_VALUE,
|
||||||
{ATTR_ENTITY_ID: ENTITY_ID, "value": -125},
|
{ATTR_ENTITY_ID: ENTITY_ID, "value": 1},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -79,7 +78,7 @@ async def test_api_failure(
|
|||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
TEST_PLATFORM,
|
TEST_PLATFORM,
|
||||||
SERVICE_SET_VALUE,
|
SERVICE_SET_VALUE,
|
||||||
{ATTR_ENTITY_ID: ENTITY_ID, "value": -125},
|
{ATTR_ENTITY_ID: ENTITY_ID, "value": 1},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
mock_myuplink_client.async_set_device_points.assert_called_once()
|
mock_myuplink_client.async_set_device_points.assert_called_once()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user