From a38b36cf34f5168c40a98641c68d3050c3df39c7 Mon Sep 17 00:00:00 2001 From: Colin Robbins Date: Wed, 28 Sep 2022 13:33:38 +0100 Subject: [PATCH] Add long term stats support to Withings sensors (#74829) --- homeassistant/components/withings/sensor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/withings/sensor.py b/homeassistant/components/withings/sensor.py index f8753739519..fbeefb2c514 100644 --- a/homeassistant/components/withings/sensor.py +++ b/homeassistant/components/withings/sensor.py @@ -1,7 +1,11 @@ """Sensors flow for Withings.""" from __future__ import annotations -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorEntity +from homeassistant.components.sensor import ( + DOMAIN as SENSOR_DOMAIN, + SensorEntity, + SensorStateClass, +) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -37,3 +41,8 @@ class WithingsHealthSensor(BaseWithingsSensor, SensorEntity): def native_unit_of_measurement(self) -> str: """Return the unit of measurement of this entity, if any.""" return self._attribute.unit_of_measurement + + @property + def state_class(self) -> str: + """Return the state_class of this entity, if any.""" + return SensorStateClass.MEASUREMENT