From 59928983401b4916edb7c05fe775f42782211260 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Wed, 10 Dec 2025 14:35:24 +0000 Subject: [PATCH] Add measurement state class to ohme sensors (#158541) --- homeassistant/components/ohme/sensor.py | 3 +++ tests/components/ohme/snapshots/test_sensor.ambr | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/ohme/sensor.py b/homeassistant/components/ohme/sensor.py index 93063966050..82c74761416 100644 --- a/homeassistant/components/ohme/sensor.py +++ b/homeassistant/components/ohme/sensor.py @@ -49,6 +49,7 @@ SENSORS = [ key="current", device_class=SensorDeviceClass.CURRENT, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, + state_class=SensorStateClass.MEASUREMENT, value_fn=lambda client: client.power.amps, ), OhmeSensorDescription( @@ -57,6 +58,7 @@ SENSORS = [ native_unit_of_measurement=UnitOfPower.WATT, suggested_unit_of_measurement=UnitOfPower.KILO_WATT, suggested_display_precision=1, + state_class=SensorStateClass.MEASUREMENT, value_fn=lambda client: client.power.watts, ), OhmeSensorDescription( @@ -81,6 +83,7 @@ SENSORS = [ native_unit_of_measurement=PERCENTAGE, device_class=SensorDeviceClass.BATTERY, suggested_display_precision=0, + state_class=SensorStateClass.MEASUREMENT, value_fn=lambda client: client.battery, ), OhmeSensorDescription( diff --git a/tests/components/ohme/snapshots/test_sensor.ambr b/tests/components/ohme/snapshots/test_sensor.ambr index f074aa8e6bd..7e7758c58cd 100644 --- a/tests/components/ohme/snapshots/test_sensor.ambr +++ b/tests/components/ohme/snapshots/test_sensor.ambr @@ -52,7 +52,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'config_subentry_id': , 'device_class': None, @@ -90,6 +92,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'current', 'friendly_name': 'Ohme Home Pro Current', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -164,7 +167,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'config_subentry_id': , 'device_class': None, @@ -205,6 +210,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'power', 'friendly_name': 'Ohme Home Pro Power', + 'state_class': , 'unit_of_measurement': , }), 'context': , @@ -286,7 +292,9 @@ 'aliases': set({ }), 'area_id': None, - 'capabilities': None, + 'capabilities': dict({ + 'state_class': , + }), 'config_entry_id': , 'config_subentry_id': , 'device_class': None, @@ -324,6 +332,7 @@ 'attributes': ReadOnlyDict({ 'device_class': 'battery', 'friendly_name': 'Ohme Home Pro Vehicle battery', + 'state_class': , 'unit_of_measurement': '%', }), 'context': ,