diff --git a/homeassistant/components/matter/icons.json b/homeassistant/components/matter/icons.json index ed0ebfce46e1dd..c191dedbceaa88 100644 --- a/homeassistant/components/matter/icons.json +++ b/homeassistant/components/matter/icons.json @@ -26,6 +26,9 @@ }, "activated_carbon_filter_condition": { "default": "mdi:filter-check" + }, + "valve_position": { + "default": "mdi:valve" } } } diff --git a/homeassistant/components/matter/sensor.py b/homeassistant/components/matter/sensor.py index 5e02fe640abf9a..9bd21e1a95d1f1 100644 --- a/homeassistant/components/matter/sensor.py +++ b/homeassistant/components/matter/sensor.py @@ -232,6 +232,16 @@ def _update_from_device(self) -> None: required_attributes=(EveCluster.Attributes.Current,), absent_clusters=(clusters.ElectricalPowerMeasurement,), ), + MatterDiscoverySchema( + platform=Platform.SENSOR, + entity_description=MatterSensorEntityDescription( + key="EveThermoValvePosition", + translation_key="valve_position", + native_unit_of_measurement=PERCENTAGE, + ), + entity_class=MatterSensor, + required_attributes=(EveCluster.Attributes.ValvePosition,), + ), MatterDiscoverySchema( platform=Platform.SENSOR, entity_description=MatterSensorEntityDescription( diff --git a/homeassistant/components/matter/strings.json b/homeassistant/components/matter/strings.json index 3ecaf6a81511a7..dd01da56d7f749 100644 --- a/homeassistant/components/matter/strings.json +++ b/homeassistant/components/matter/strings.json @@ -168,6 +168,9 @@ }, "switch_current_position": { "name": "Current switch position" + }, + "valve_position": { + "name": "Valve position" } }, "switch": { diff --git a/tests/components/matter/fixtures/nodes/eve-thermo.json b/tests/components/matter/fixtures/nodes/eve-thermo.json new file mode 100644 index 00000000000000..e00b55d2cfc750 --- /dev/null +++ b/tests/components/matter/fixtures/nodes/eve-thermo.json @@ -0,0 +1,406 @@ +{ + "node_id": 33, + "date_commissioned": "2024-09-11T05:47:53.888591", + "last_interview": "2024-09-11T05:48:45.828762", + "interview_version": 6, + "available": true, + "is_bridge": false, + "attributes": { + "0/29/0": [ + { + "0": 18, + "1": 1 + }, + { + "0": 17, + "1": 1 + }, + { + "0": 22, + "1": 2 + } + ], + "0/29/1": [29, 31, 40, 42, 47, 48, 49, 50, 51, 52, 53, 56, 60, 62, 63, 70], + "0/29/2": [41], + "0/29/3": [1], + "0/29/65532": 0, + "0/29/65533": 2, + "0/29/65528": [], + "0/29/65529": [], + "0/29/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533], + "0/31/0": [ + { + "254": 1 + }, + { + "254": 1 + }, + { + "254": 2 + }, + { + "254": 3 + }, + { + "1": 5, + "2": 2, + "3": [112233], + "4": null, + "254": 4 + } + ], + "0/31/1": [], + "0/31/2": 10, + "0/31/3": 3, + "0/31/4": 5, + "0/31/65532": 0, + "0/31/65533": 1, + "0/31/65528": [], + "0/31/65529": [], + "0/31/65531": [0, 1, 2, 3, 4, 65528, 65529, 65531, 65532, 65533], + "0/40/0": 17, + "0/40/1": "Eve Systems", + "0/40/2": 4874, + "0/40/3": "Eve Thermo", + "0/40/4": 79, + "0/40/5": "", + "0/40/6": "**REDACTED**", + "0/40/7": 1, + "0/40/8": "1.1", + "0/40/9": 9217, + "0/40/10": "3.5.0", + "0/40/15": "**REDACTED**", + "0/40/18": "**REDACTED**", + "0/40/19": { + "0": 3, + "1": 3 + }, + "0/40/21": 16973824, + "0/40/22": 1, + "0/40/65532": 0, + "0/40/65533": 3, + "0/40/65528": [], + "0/40/65529": [], + "0/40/65531": [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 18, 19, 21, 22, 65528, 65529, 65531, + 65532, 65533 + ], + "0/42/0": [ + { + "1": 556220604, + "2": 0, + "254": 1 + } + ], + "0/42/1": true, + "0/42/2": 1, + "0/42/3": null, + "0/42/65532": 0, + "0/42/65533": 1, + "0/42/65528": [], + "0/42/65529": [0], + "0/42/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533], + "0/47/0": 1, + "0/47/1": 0, + "0/47/2": "Battery", + "0/47/11": 3050, + "0/47/12": 200, + "0/47/14": 0, + "0/47/15": false, + "0/47/16": 2, + "0/47/18": [], + "0/47/19": "", + "0/47/25": 1, + "0/47/31": [], + "0/47/65532": 10, + "0/47/65533": 2, + "0/47/65528": [], + "0/47/65529": [], + "0/47/65531": [ + 0, 1, 2, 11, 12, 14, 15, 16, 18, 19, 25, 31, 65528, 65529, 65531, 65532, + 65533 + ], + "0/48/0": 0, + "0/48/1": { + "0": 60, + "1": 900 + }, + "0/48/2": 0, + "0/48/3": 0, + "0/48/4": true, + "0/48/65532": 0, + "0/48/65533": 1, + "0/48/65528": [1, 3, 5], + "0/48/65529": [0, 2, 4], + "0/48/65531": [0, 1, 2, 3, 4, 65528, 65529, 65531, 65532, 65533], + "0/49/0": 1, + "0/49/1": [], + "0/49/2": 10, + "0/49/3": 20, + "0/49/4": true, + "0/49/5": 0, + "0/49/6": "**REDACTED**", + "0/49/7": null, + "0/49/9": 4, + "0/49/10": 4, + "0/49/65532": 2, + "0/49/65533": 2, + "0/49/65528": [1, 5, 7], + "0/49/65529": [0, 3, 4, 6, 8], + "0/49/65531": [ + 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 65528, 65529, 65531, 65532, 65533 + ], + "0/50/65532": 0, + "0/50/65533": 1, + "0/50/65528": [1], + "0/50/65529": [0], + "0/50/65531": [65528, 65529, 65531, 65532, 65533], + "0/51/0": [], + "0/51/1": 2, + "0/51/2": 306352, + "0/51/3": 85, + "0/51/5": [], + "0/51/6": [], + "0/51/7": [], + "0/51/8": false, + "0/51/65532": 0, + "0/51/65533": 2, + "0/51/65528": [2], + "0/51/65529": [0, 1], + "0/51/65531": [0, 1, 2, 3, 5, 6, 7, 8, 65528, 65529, 65531, 65532, 65533], + "0/52/1": 10168, + "0/52/2": 1948, + "0/52/65532": 0, + "0/52/65533": 1, + "0/52/65528": [], + "0/52/65529": [], + "0/52/65531": [1, 2, 65528, 65529, 65531, 65532, 65533], + "0/53/0": 25, + "0/53/1": 2, + "0/53/2": "**REDACTED**", + "0/53/3": 4660, + "0/53/4": 12054125955590472924, + "0/53/5": "**REDACTED**", + "0/53/6": 0, + "0/53/7": [], + "0/53/8": [], + "0/53/9": 867525816, + "0/53/10": 68, + "0/53/11": 127, + "0/53/12": 197, + "0/53/13": 17, + "0/53/14": 4, + "0/53/15": 4, + "0/53/16": 0, + "0/53/17": 0, + "0/53/18": 13, + "0/53/19": 3, + "0/53/20": 0, + "0/53/21": 3, + "0/53/22": 167566, + "0/53/23": 167438, + "0/53/24": 128, + "0/53/25": 167438, + "0/53/26": 167326, + "0/53/27": 128, + "0/53/28": 14672, + "0/53/29": 152900, + "0/53/30": 0, + "0/53/31": 0, + "0/53/32": 0, + "0/53/33": 30814, + "0/53/34": 63, + "0/53/35": 0, + "0/53/36": 37, + "0/53/37": 0, + "0/53/38": 0, + "0/53/39": 16473, + "0/53/40": 7569, + "0/53/41": 23, + "0/53/42": 7273, + "0/53/43": 0, + "0/53/44": 0, + "0/53/45": 0, + "0/53/46": 0, + "0/53/47": 0, + "0/53/48": 6541, + "0/53/49": 319, + "0/53/50": 105, + "0/53/51": 1500, + "0/53/52": 0, + "0/53/53": 0, + "0/53/54": 681, + "0/53/55": 54, + "0/53/59": { + "0": 672, + "1": 8335 + }, + "0/53/60": "AB//4A==", + "0/53/61": { + "0": true, + "1": false, + "2": true, + "3": true, + "4": true, + "5": true, + "6": false, + "7": true, + "8": true, + "9": true, + "10": true, + "11": true + }, + "0/53/62": [], + "0/53/65532": 15, + "0/53/65533": 2, + "0/53/65528": [], + "0/53/65529": [0], + "0/53/65531": [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 59, + 60, 61, 62, 65528, 65529, 65531, 65532, 65533 + ], + "0/56/0": 779348920474853, + "0/56/1": 4, + "0/56/2": 2, + "0/56/3": null, + "0/56/5": [ + { + "0": 3600, + "1": 0, + "2": "Europe/Paris" + } + ], + "0/56/6": [ + { + "0": 3600, + "1": 0, + "2": 783306000000000 + }, + { + "0": 0, + "1": 783306000000000, + "2": 796611600000000 + } + ], + "0/56/7": 779356121143951, + "0/56/8": 2, + "0/56/10": 2, + "0/56/11": 2, + "0/56/65532": 9, + "0/56/65533": 2, + "0/56/65528": [3], + "0/56/65529": [0, 1, 2, 4], + "0/56/65531": [ + 0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 65528, 65529, 65531, 65532, 65533 + ], + "0/60/0": 0, + "0/60/1": null, + "0/60/2": null, + "0/60/65532": 1, + "0/60/65533": 1, + "0/60/65528": [], + "0/60/65529": [0, 1, 2], + "0/60/65531": [0, 1, 2, 65528, 65529, 65531, 65532, 65533], + "0/62/0": [], + "0/62/1": [], + "0/62/2": 5, + "0/62/3": 4, + "0/62/4": [], + "0/62/5": 4, + "0/62/65532": 0, + "0/62/65533": 1, + "0/62/65528": [1, 3, 5, 8], + "0/62/65529": [0, 2, 4, 6, 7, 9, 10, 11], + "0/62/65531": [0, 1, 2, 3, 4, 5, 65528, 65529, 65531, 65532, 65533], + "0/63/0": [], + "0/63/1": [], + "0/63/2": 4, + "0/63/3": 3, + "0/63/65532": 0, + "0/63/65533": 2, + "0/63/65528": [2, 5], + "0/63/65529": [0, 1, 3, 4], + "0/63/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533], + "0/70/0": 120, + "0/70/1": 300, + "0/70/2": 2000, + "0/70/65532": 0, + "0/70/65533": 2, + "0/70/65528": [], + "0/70/65529": [], + "0/70/65531": [0, 1, 2, 65528, 65529, 65531, 65532, 65533], + "1/3/0": 0, + "1/3/1": 4, + "1/3/65532": 0, + "1/3/65533": 4, + "1/3/65528": [], + "1/3/65529": [0], + "1/3/65531": [0, 1, 65528, 65529, 65531, 65532, 65533], + "1/29/0": [ + { + "0": 769, + "1": 3 + } + ], + "1/29/1": [3, 29, 30, 513, 516, 319486977], + "1/29/2": [1026], + "1/29/3": [], + "1/29/65532": 0, + "1/29/65533": 2, + "1/29/65528": [], + "1/29/65529": [], + "1/29/65531": [0, 1, 2, 3, 65528, 65529, 65531, 65532, 65533], + "1/30/0": [], + "1/30/65532": 0, + "1/30/65533": 1, + "1/30/65528": [], + "1/30/65529": [], + "1/30/65531": [0, 65528, 65529, 65531, 65532, 65533], + "1/513/0": 2100, + "1/513/3": 1000, + "1/513/4": 3000, + "1/513/16": 0, + "1/513/18": 1700, + "1/513/21": 1000, + "1/513/22": 3000, + "1/513/26": 0, + "1/513/27": 2, + "1/513/28": 4, + "1/513/65532": 1, + "1/513/65533": 6, + "1/513/65528": [], + "1/513/65529": [0], + "1/513/65531": [ + 0, 3, 4, 16, 18, 21, 22, 26, 27, 28, 65528, 65529, 65531, 65532, 65533 + ], + "1/516/0": 0, + "1/516/1": 0, + "1/516/2": 0, + "1/516/65532": 0, + "1/516/65533": 2, + "1/516/65528": [], + "1/516/65529": [], + "1/516/65531": [0, 1, 2, 65528, 65529, 65531, 65532, 65533], + "1/319486977/319422464": "AAFPCwIAAAMCEyQEDENNMzRNMUE0NzgxNZwBAP8EAQIIMPkBAR0BAD4AOwhTVEVHVDIxMjwBADcBAD8BACYBAScBHk8GAAAgICoq/wMjAQBFDQUCAAAAAAACAYk0BaVGVAXKISyfJEkCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEkGBQwIEIABRBEFHAAFAzwAAADhKT5Ch1orv0cRBSoh/CGWImgjtAAAADwAAABIBgUAAAAAAEoGBQAAAAAA/ygiCRABAAAAAAAAAAIb0XT3kNTbRpuy/pzwUAklhFBhciBkw6lmYXV0", + "1/319486977/319422466": "xqwEAFjkAwBNnpAsBgECEQIQARIBHQEjAgwCABAAAAAAEQAAAAEAAA==", + "1/319486977/319422467": "EwoCAAC8rAQAPwIIKAoUAQADDAwLAgAAvKwEACDqCw==", + "1/319486977/319422476": 0, + "1/319486977/319422482": 12296, + "1/319486977/319422487": false, + "1/319486977/319422488": 10, + "1/319486977/319422489": 30240, + "1/319486977/319422490": 0, + "1/319486977/65532": 0, + "1/319486977/65533": 1, + "1/319486977/65528": [], + "1/319486977/65529": [319422464], + "1/319486977/65531": [ + 65528, 65529, 65531, 319422464, 319422465, 319422466, 319422467, + 319422468, 319422469, 319422476, 319422482, 319422487, 319422488, + 319422489, 319422490, 65532, 65533 + ] + }, + "attribute_subscriptions": [] +} diff --git a/tests/components/matter/test_sensor.py b/tests/components/matter/test_sensor.py index c8f89eb8f0c13b..d887ff4d23361c 100644 --- a/tests/components/matter/test_sensor.py +++ b/tests/components/matter/test_sensor.py @@ -74,6 +74,14 @@ async def eve_energy_plug_node_fixture( ) +@pytest.fixture(name="eve_thermo_node") +async def eve_thermo_node_fixture( + hass: HomeAssistant, matter_client: MagicMock +) -> MatterNode: + """Fixture for a Eve Thermo node.""" + return await setup_integration_with_node_fixture(hass, "eve-thermo", matter_client) + + @pytest.fixture(name="eve_energy_plug_patched_node") async def eve_energy_plug_patched_node_fixture( hass: HomeAssistant, matter_client: MagicMock @@ -384,6 +392,27 @@ async def test_energy_sensors( assert state is None +# This tests needs to be adjusted to remove lingering tasks +@pytest.mark.parametrize("expected_lingering_tasks", [True]) +async def test_eve_thermo_sensor( + hass: HomeAssistant, + matter_client: MagicMock, + eve_thermo_node: MatterNode, +) -> None: + """Test Eve Thermo.""" + # Valve position + state = hass.states.get("sensor.eve_thermo_valve_position") + assert state + assert state.state == "10" + + set_node_attribute(eve_thermo_node, 1, 319486977, 319422488, 0) + await trigger_subscription_callback(hass, matter_client) + + state = hass.states.get("sensor.eve_thermo_valve_position") + assert state + assert state.state == "0" + + # This tests needs to be adjusted to remove lingering tasks @pytest.mark.parametrize("expected_lingering_tasks", [True]) async def test_air_quality_sensor(