Add state_class_measurement to nws (#56629)

This commit is contained in:
MatthewFlamm 2021-09-25 05:58:07 -04:00 committed by GitHub
parent 917254e956
commit 8bc8081e81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,10 @@ from __future__ import annotations
from dataclasses import dataclass
from datetime import timedelta
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,
@ -113,6 +116,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Dew Point",
icon=None,
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=TEMP_CELSIUS,
unit_convert=TEMP_CELSIUS,
),
@ -121,6 +125,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Temperature",
icon=None,
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=TEMP_CELSIUS,
unit_convert=TEMP_CELSIUS,
),
@ -129,6 +134,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Wind Chill",
icon=None,
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=TEMP_CELSIUS,
unit_convert=TEMP_CELSIUS,
),
@ -137,6 +143,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Heat Index",
icon=None,
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=TEMP_CELSIUS,
unit_convert=TEMP_CELSIUS,
),
@ -145,6 +152,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Relative Humidity",
icon=None,
device_class=DEVICE_CLASS_HUMIDITY,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=PERCENTAGE,
unit_convert=PERCENTAGE,
),
@ -153,6 +161,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Wind Speed",
icon="mdi:weather-windy",
device_class=None,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
unit_convert=SPEED_MILES_PER_HOUR,
),
@ -161,6 +170,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Wind Gust",
icon="mdi:weather-windy",
device_class=None,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
unit_convert=SPEED_MILES_PER_HOUR,
),
@ -169,6 +179,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Wind Direction",
icon="mdi:compass-rose",
device_class=None,
state_class=None, # statistics currently doesn't handle circular statistics
native_unit_of_measurement=DEGREE,
unit_convert=DEGREE,
),
@ -177,6 +188,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Barometric Pressure",
icon=None,
device_class=DEVICE_CLASS_PRESSURE,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=PRESSURE_PA,
unit_convert=PRESSURE_INHG,
),
@ -185,6 +197,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Sea Level Pressure",
icon=None,
device_class=DEVICE_CLASS_PRESSURE,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=PRESSURE_PA,
unit_convert=PRESSURE_INHG,
),
@ -193,6 +206,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
name="Visibility",
icon="mdi:eye",
device_class=None,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=LENGTH_METERS,
unit_convert=LENGTH_MILES,
),