Add long term stats support to Withings sensors (#74829)

This commit is contained in:
Colin Robbins 2022-09-28 13:33:38 +01:00 committed by GitHub
parent 4453241176
commit a38b36cf34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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