Use enums in trafikverket_weatherstation (#62027)

pull/62102/head
Robert Hillis 2021-12-16 07:05:46 -05:00 committed by GitHub
parent e713a597ec
commit b4daa88d9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 13 deletions

View File

@ -13,9 +13,10 @@ import voluptuous as vol
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA, PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
STATE_CLASS_MEASUREMENT, SensorDeviceClass,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass,
) )
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
@ -24,8 +25,6 @@ from homeassistant.const import (
CONF_MONITORED_CONDITIONS, CONF_MONITORED_CONDITIONS,
CONF_NAME, CONF_NAME,
DEGREE, DEGREE,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE,
LENGTH_MILLIMETERS, LENGTH_MILLIMETERS,
PERCENTAGE, PERCENTAGE,
SPEED_METERS_PER_SECOND, SPEED_METERS_PER_SECOND,
@ -71,8 +70,8 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
name="Air temperature", name="Air temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
icon="mdi:thermometer", icon="mdi:thermometer",
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
TrafikverketSensorEntityDescription( TrafikverketSensorEntityDescription(
key="road_temp", key="road_temp",
@ -80,8 +79,8 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
name="Road temperature", name="Road temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
icon="mdi:thermometer", icon="mdi:thermometer",
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
TrafikverketSensorEntityDescription( TrafikverketSensorEntityDescription(
key="precipitation", key="precipitation",
@ -96,7 +95,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
name="Wind direction", name="Wind direction",
native_unit_of_measurement=DEGREE, native_unit_of_measurement=DEGREE,
icon="mdi:flag-triangle", icon="mdi:flag-triangle",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
TrafikverketSensorEntityDescription( TrafikverketSensorEntityDescription(
key="wind_direction_text", key="wind_direction_text",
@ -110,7 +109,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
name="Wind speed", name="Wind speed",
native_unit_of_measurement=SPEED_METERS_PER_SECOND, native_unit_of_measurement=SPEED_METERS_PER_SECOND,
icon="mdi:weather-windy", icon="mdi:weather-windy",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
TrafikverketSensorEntityDescription( TrafikverketSensorEntityDescription(
key="wind_speed_max", key="wind_speed_max",
@ -119,7 +118,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
native_unit_of_measurement=SPEED_METERS_PER_SECOND, native_unit_of_measurement=SPEED_METERS_PER_SECOND,
icon="mdi:weather-windy-variant", icon="mdi:weather-windy-variant",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
TrafikverketSensorEntityDescription( TrafikverketSensorEntityDescription(
key="humidity", key="humidity",
@ -127,9 +126,9 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
name="Humidity", name="Humidity",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:water-percent", icon="mdi:water-percent",
device_class=DEVICE_CLASS_HUMIDITY, device_class=SensorDeviceClass.HUMIDITY,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
TrafikverketSensorEntityDescription( TrafikverketSensorEntityDescription(
key="precipitation_amount", key="precipitation_amount",
@ -137,7 +136,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
name="Precipitation amount", name="Precipitation amount",
native_unit_of_measurement=LENGTH_MILLIMETERS, native_unit_of_measurement=LENGTH_MILLIMETERS,
icon="mdi:cup-water", icon="mdi:cup-water",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
TrafikverketSensorEntityDescription( TrafikverketSensorEntityDescription(
key="precipitation_amountname", key="precipitation_amountname",