From 75d02661ebe0fa34987b2c41753c6dc2bc06aaba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20BOU=C3=89?= Date: Fri, 14 Nov 2025 17:19:28 +0000 Subject: [PATCH] Add Setpoint Change Source sensor and localization strings --- homeassistant/components/matter/sensor.py | 19 ++++++ homeassistant/components/matter/strings.json | 8 +++ .../matter/fixtures/nodes/thermostat.json | 1 + .../matter/snapshots/test_sensor.ambr | 60 +++++++++++++++++++ 4 files changed, 88 insertions(+) diff --git a/homeassistant/components/matter/sensor.py b/homeassistant/components/matter/sensor.py index f7603c9fde9..e018bcedda7 100644 --- a/homeassistant/components/matter/sensor.py +++ b/homeassistant/components/matter/sensor.py @@ -183,6 +183,13 @@ PUMP_CONTROL_MODE_MAP = { clusters.PumpConfigurationAndControl.Enums.ControlModeEnum.kUnknownEnumValue: None, } +SETPOINT_CHANGE_SOURCE_MAP = { + clusters.Thermostat.Enums.SetpointChangeSourceEnum.kManual: "manual", + clusters.Thermostat.Enums.SetpointChangeSourceEnum.kSchedule: "schedule", + clusters.Thermostat.Enums.SetpointChangeSourceEnum.kExternal: "external", + clusters.Thermostat.Enums.SetpointChangeSourceEnum.kUnknownEnumValue: None, +} + HUMIDITY_SCALING_FACTOR = 100 TEMPERATURE_SCALING_FACTOR = 100 @@ -1488,4 +1495,16 @@ DISCOVERY_SCHEMAS = [ entity_class=MatterSensor, required_attributes=(clusters.ServiceArea.Attributes.EstimatedEndTime,), ), + MatterDiscoverySchema( + platform=Platform.SENSOR, + entity_description=MatterSensorEntityDescription( + key="SetpointChangeSource", + translation_key="setpoint_change_source", + device_class=SensorDeviceClass.ENUM, + options=[v for v in SETPOINT_CHANGE_SOURCE_MAP.values() if v is not None], + device_to_ha=SETPOINT_CHANGE_SOURCE_MAP.get, + ), + entity_class=MatterSensor, + required_attributes=(clusters.Thermostat.Attributes.SetpointChangeSource,), + ), ] diff --git a/homeassistant/components/matter/strings.json b/homeassistant/components/matter/strings.json index e6c2e6cc6d2..0d54137e05a 100644 --- a/homeassistant/components/matter/strings.json +++ b/homeassistant/components/matter/strings.json @@ -518,6 +518,14 @@ "rms_voltage": { "name": "Effective voltage" }, + "setpoint_change_source": { + "name": "Setpoint change source", + "state": { + "external": "External", + "manual": "Manual", + "schedule": "Schedule" + } + }, "switch_current_position": { "name": "Current switch position" }, diff --git a/tests/components/matter/fixtures/nodes/thermostat.json b/tests/components/matter/fixtures/nodes/thermostat.json index 620738d2e7e..53ac9f1aa86 100644 --- a/tests/components/matter/fixtures/nodes/thermostat.json +++ b/tests/components/matter/fixtures/nodes/thermostat.json @@ -334,6 +334,7 @@ "1/513/27": 4, "1/513/28": 3, "1/513/30": 0, + "1/513/48": 0, "1/513/65532": 35, "1/513/65533": 5, "1/513/65528": [], diff --git a/tests/components/matter/snapshots/test_sensor.ambr b/tests/components/matter/snapshots/test_sensor.ambr index 089db73bc15..dd81d32c810 100644 --- a/tests/components/matter/snapshots/test_sensor.ambr +++ b/tests/components/matter/snapshots/test_sensor.ambr @@ -10507,6 +10507,66 @@ 'state': '12.5', }) # --- +# name: test_sensors[thermostat][sensor.longan_link_hvac_setpoint_change_source-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'options': list([ + 'manual', + 'schedule', + 'external', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.longan_link_hvac_setpoint_change_source', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Setpoint change source', + 'platform': 'matter', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'setpoint_change_source', + 'unique_id': '00000000000004D2-0000000000000004-MatterNodeDevice-1-SetpointChangeSource-513-48', + 'unit_of_measurement': None, + }) +# --- +# name: test_sensors[thermostat][sensor.longan_link_hvac_setpoint_change_source-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'enum', + 'friendly_name': 'Longan link HVAC Setpoint change source', + 'options': list([ + 'manual', + 'schedule', + 'external', + ]), + }), + 'context': , + 'entity_id': 'sensor.longan_link_hvac_setpoint_change_source', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'manual', + }) +# --- # name: test_sensors[thermostat][sensor.longan_link_hvac_temperature-entry] EntityRegistryEntrySnapshot({ 'aliases': set({