From 5411a75b79dc0d18c012b2e59f7b4d115770797a Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Mon, 6 Apr 2026 14:24:02 +0000 Subject: [PATCH] fix(sensor): set state_class=None on static diagnostic metadata sensors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four non-MONETARY diagnostic sensors had state_class set, causing HA Recorder to add them to long-term statistics tables unnecessarily: - home_size (m²): SensorStateClass.MEASUREMENT - main_fuse_size (A): SensorStateClass.MEASUREMENT - number_of_residents: SensorStateClass.MEASUREMENT - estimated_annual_consumption(kWh):SensorStateClass.TOTAL All four are static user metadata retrieved from Tibber's user API (cached for 24 h, rarely or never changes in practice). They carry no time-series value: home_size and main_fuse_size don't change, and estimated_annual_consumption is a rough Tibber estimate, not an actual accumulating energy counter. Setting state_class=None removes them from long-term statistics while keeping normal state-change recording intact. The three intentional non-None state_class values are unchanged: - current_interval_price (MONETARY, TOTAL): Energy Dashboard - current_interval_price_base (MONETARY, TOTAL): Energy Dashboard - average_price_today (MONETARY, TOTAL): useful weekly/monthly trend Impact: Reduced Recorder database growth; no user-visible sensor behaviour change. --- custom_components/tibber_prices/sensor/definitions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/tibber_prices/sensor/definitions.py b/custom_components/tibber_prices/sensor/definitions.py index e9d6b51..8f437ec 100644 --- a/custom_components/tibber_prices/sensor/definitions.py +++ b/custom_components/tibber_prices/sensor/definitions.py @@ -796,7 +796,7 @@ DIAGNOSTIC_SENSORS = ( icon="mdi:ruler-square", entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfArea.SQUARE_METERS, - state_class=SensorStateClass.MEASUREMENT, + state_class=None, # Static user metadata: no statistics useful entity_registry_enabled_default=False, suggested_display_precision=0, ), @@ -807,7 +807,7 @@ DIAGNOSTIC_SENSORS = ( entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfElectricCurrent.AMPERE, device_class=SensorDeviceClass.CURRENT, - state_class=SensorStateClass.MEASUREMENT, + state_class=None, # Static user metadata: no statistics useful entity_registry_enabled_default=False, suggested_display_precision=0, ), @@ -816,7 +816,7 @@ DIAGNOSTIC_SENSORS = ( translation_key="number_of_residents", icon="mdi:account-group", entity_category=EntityCategory.DIAGNOSTIC, - state_class=SensorStateClass.MEASUREMENT, + state_class=None, # Static user metadata: no statistics useful entity_registry_enabled_default=False, suggested_display_precision=0, ), @@ -902,7 +902,7 @@ DIAGNOSTIC_SENSORS = ( entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, device_class=SensorDeviceClass.ENERGY, - state_class=SensorStateClass.TOTAL, + state_class=None, # Static Tibber estimate, not an actual accumulating counter suggested_display_precision=0, ), # Subscription data