From 55ffc85a0a5b36e60ba156a70f59efb37ea914bc Mon Sep 17 00:00:00 2001 From: David K Turner Date: Fri, 22 Oct 2021 07:19:19 -0500 Subject: [PATCH] Enable long-term statistics for OpenWeatherMap sensors (#57781) --- homeassistant/components/openweathermap/const.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/openweathermap/const.py b/homeassistant/components/openweathermap/const.py index 7647d64d7a2..607f223167f 100644 --- a/homeassistant/components/openweathermap/const.py +++ b/homeassistant/components/openweathermap/const.py @@ -1,7 +1,10 @@ """Consts for the OpenWeatherMap.""" from __future__ import annotations -from homeassistant.components.sensor import SensorEntityDescription +from homeassistant.components.sensor import ( + STATE_CLASS_MEASUREMENT, + SensorEntityDescription, +) from homeassistant.components.weather import ( ATTR_CONDITION_CLOUDY, ATTR_CONDITION_EXCEPTIONAL, @@ -173,55 +176,65 @@ WEATHER_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( name="Dew Point", native_unit_of_measurement=TEMP_CELSIUS, device_class=DEVICE_CLASS_TEMPERATURE, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_TEMPERATURE, name="Temperature", native_unit_of_measurement=TEMP_CELSIUS, device_class=DEVICE_CLASS_TEMPERATURE, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_FEELS_LIKE_TEMPERATURE, name="Feels like temperature", native_unit_of_measurement=TEMP_CELSIUS, device_class=DEVICE_CLASS_TEMPERATURE, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_WIND_SPEED, name="Wind speed", native_unit_of_measurement=SPEED_METERS_PER_SECOND, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_WIND_BEARING, name="Wind bearing", native_unit_of_measurement=DEGREE, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_HUMIDITY, name="Humidity", native_unit_of_measurement=PERCENTAGE, device_class=DEVICE_CLASS_HUMIDITY, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_PRESSURE, name="Pressure", native_unit_of_measurement=PRESSURE_HPA, device_class=DEVICE_CLASS_PRESSURE, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_CLOUDS, name="Cloud coverage", native_unit_of_measurement=PERCENTAGE, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_RAIN, name="Rain", native_unit_of_measurement=LENGTH_MILLIMETERS, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_SNOW, name="Snow", native_unit_of_measurement=LENGTH_MILLIMETERS, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_PRECIPITATION_KIND, @@ -231,6 +244,7 @@ WEATHER_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( key=ATTR_API_UV_INDEX, name="UV Index", native_unit_of_measurement=UV_INDEX, + state_class=STATE_CLASS_MEASUREMENT, ), SensorEntityDescription( key=ATTR_API_CONDITION,