Use new enums in nws (#61947)
parent
e1a7f6d1b2
commit
2cc343bb7f
|
@ -5,8 +5,9 @@ from dataclasses import dataclass
|
|||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
SensorDeviceClass,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.components.weather import (
|
||||
ATTR_CONDITION_CLOUDY,
|
||||
|
@ -25,9 +26,6 @@ from homeassistant.components.weather import (
|
|||
)
|
||||
from homeassistant.const import (
|
||||
DEGREE,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
LENGTH_METERS,
|
||||
LENGTH_MILES,
|
||||
PERCENTAGE,
|
||||
|
@ -115,8 +113,8 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
key="dewpoint",
|
||||
name="Dew Point",
|
||||
icon=None,
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
unit_convert=TEMP_CELSIUS,
|
||||
),
|
||||
|
@ -124,8 +122,8 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
key="temperature",
|
||||
name="Temperature",
|
||||
icon=None,
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
unit_convert=TEMP_CELSIUS,
|
||||
),
|
||||
|
@ -133,8 +131,8 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
key="windChill",
|
||||
name="Wind Chill",
|
||||
icon=None,
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
unit_convert=TEMP_CELSIUS,
|
||||
),
|
||||
|
@ -142,8 +140,8 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
key="heatIndex",
|
||||
name="Heat Index",
|
||||
icon=None,
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
unit_convert=TEMP_CELSIUS,
|
||||
),
|
||||
|
@ -151,8 +149,8 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
key="relativeHumidity",
|
||||
name="Relative Humidity",
|
||||
icon=None,
|
||||
device_class=DEVICE_CLASS_HUMIDITY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
unit_convert=PERCENTAGE,
|
||||
),
|
||||
|
@ -161,7 +159,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
name="Wind Speed",
|
||||
icon="mdi:weather-windy",
|
||||
device_class=None,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
|
||||
unit_convert=SPEED_MILES_PER_HOUR,
|
||||
),
|
||||
|
@ -170,7 +168,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
name="Wind Gust",
|
||||
icon="mdi:weather-windy",
|
||||
device_class=None,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
|
||||
unit_convert=SPEED_MILES_PER_HOUR,
|
||||
),
|
||||
|
@ -187,8 +185,8 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
key="barometricPressure",
|
||||
name="Barometric Pressure",
|
||||
icon=None,
|
||||
device_class=DEVICE_CLASS_PRESSURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=PRESSURE_PA,
|
||||
unit_convert=PRESSURE_INHG,
|
||||
),
|
||||
|
@ -196,8 +194,8 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
key="seaLevelPressure",
|
||||
name="Sea Level Pressure",
|
||||
icon=None,
|
||||
device_class=DEVICE_CLASS_PRESSURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=PRESSURE_PA,
|
||||
unit_convert=PRESSURE_INHG,
|
||||
),
|
||||
|
@ -206,7 +204,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = (
|
|||
name="Visibility",
|
||||
icon="mdi:eye",
|
||||
device_class=None,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=LENGTH_METERS,
|
||||
unit_convert=LENGTH_MILES,
|
||||
),
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
"""Sensors for National Weather Service (NWS)."""
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
LENGTH_METERS,
|
||||
|
@ -57,7 +56,7 @@ class NWSSensor(CoordinatorEntity, SensorEntity):
|
|||
"""An NWS Sensor Entity."""
|
||||
|
||||
entity_description: NWSSensorEntityDescription
|
||||
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
_attr_attribution = ATTRIBUTION
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
|
Loading…
Reference in New Issue