From 6a69e17bfe38947de6024d1f7156af0c8f0ff4ee Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Sat, 3 Oct 2026 13:09:36 +0200 Subject: [PATCH] Mark mapping sensors as enum for nibe heatpump (#184117) --- .../components/nibe_heatpump/sensor.py | 5 ++++- .../nibe_heatpump/snapshots/test_sensor.ambr | 20 +++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/nibe_heatpump/sensor.py b/homeassistant/components/nibe_heatpump/sensor.py index 675dfbf220bd..ed4b2458f5af 100644 --- a/homeassistant/components/nibe_heatpump/sensor.py +++ b/homeassistant/components/nibe_heatpump/sensor.py @@ -249,7 +249,10 @@ class Sensor(CoilEntity, SensorEntity): if state_class := NATURE_TO_STATE_CLASS.get(coil.nature): self._attr_state_class = state_class - if not coil.mappings: + if coil.mappings: + self._attr_device_class = SensorDeviceClass.ENUM + self._attr_options = list(coil.mappings.values()) + else: self._attr_suggested_display_precision = ceil(log10(abs(coil.factor))) @override diff --git a/tests/components/nibe_heatpump/snapshots/test_sensor.ambr b/tests/components/nibe_heatpump/snapshots/test_sensor.ambr index 7fe6a5c5d545..3878b53a7002 100644 --- a/tests/components/nibe_heatpump/snapshots/test_sensor.ambr +++ b/tests/components/nibe_heatpump/snapshots/test_sensor.ambr @@ -232,7 +232,15 @@ None, ]), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + : list([ + 'OFF', + 'STARTING', + 'ON', + '10-DAY MODE', + 'CALIBRATION', + ]), + }), 'config_entry_id': , 'config_subentry_id': , 'device_class': None, @@ -251,7 +259,7 @@ 'object_id_base': None, 'options': dict({ }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Supply Pump State EP14', 'platform': 'nibe_heatpump', @@ -266,7 +274,15 @@ # name: test_entities[Model.F1155-data0][sensor.supply_pump_state_ep14_43431-state] StateSnapshot({ 'attributes': ReadOnlyDict({ + : 'enum', : 'F1155 Supply Pump State EP14', + : list([ + 'OFF', + 'STARTING', + 'ON', + '10-DAY MODE', + 'CALIBRATION', + ]), }), 'context': , 'entity_id': 'sensor.supply_pump_state_ep14_43431',