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