From 99b0fe07463dcfe392040bf54e5e8632e5bcc735 Mon Sep 17 00:00:00 2001 From: Thomas Freudenberg Date: Mon, 6 May 2024 21:09:06 +0200 Subject: [PATCH] Enable statistics for distance sensor Sets `state_class` for distance sensor to `measurement` --- custom_components/blitzortung/sensor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/blitzortung/sensor.py b/custom_components/blitzortung/sensor.py index ff60764..061a0a7 100644 --- a/custom_components/blitzortung/sensor.py +++ b/custom_components/blitzortung/sensor.py @@ -1,7 +1,7 @@ import logging from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME, DEGREE, UnitOfLength -from homeassistant.components.sensor import SensorDeviceClass, SensorEntity +from homeassistant.components.sensor import SensorDeviceClass, SensorEntity, SensorStateClass from homeassistant.helpers.device_registry import DeviceEntryType from .const import ( @@ -144,6 +144,7 @@ def tick(self): class DistanceSensor(LightningSensor): kind = SensorDeviceClass.DISTANCE device_class = SensorDeviceClass.DISTANCE + state_class = SensorStateClass.MEASUREMENT _attr_native_unit_of_measurement = UnitOfLength.KILOMETERS def update_lightning(self, lightning):