Use enums in wirelesstag (#61985)

This commit is contained in:
Robert Hillis 2021-12-16 03:01:46 -05:00 committed by GitHub
parent 9084a227fd
commit 2e0fc65bf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,16 +7,12 @@ import voluptuous as vol
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
STATE_CLASS_MEASUREMENT, SensorDeviceClass,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass,
) )
from homeassistant.const import ( from homeassistant.const import CONF_MONITORED_CONDITIONS
CONF_MONITORED_CONDITIONS,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_TEMPERATURE,
)
from homeassistant.core import callback from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -34,28 +30,28 @@ SENSOR_LIGHT = "light"
SENSOR_TYPES: dict[str, SensorEntityDescription] = { SENSOR_TYPES: dict[str, SensorEntityDescription] = {
SENSOR_TEMPERATURE: SensorEntityDescription( SENSOR_TEMPERATURE: SensorEntityDescription(
key=SENSOR_TEMPERATURE, key=SENSOR_TEMPERATURE,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SENSOR_AMBIENT_TEMPERATURE: SensorEntityDescription( SENSOR_AMBIENT_TEMPERATURE: SensorEntityDescription(
key=SENSOR_AMBIENT_TEMPERATURE, key=SENSOR_AMBIENT_TEMPERATURE,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SENSOR_HUMIDITY: SensorEntityDescription( SENSOR_HUMIDITY: SensorEntityDescription(
key=SENSOR_HUMIDITY, key=SENSOR_HUMIDITY,
device_class=DEVICE_CLASS_HUMIDITY, device_class=SensorDeviceClass.HUMIDITY,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SENSOR_MOISTURE: SensorEntityDescription( SENSOR_MOISTURE: SensorEntityDescription(
key=SENSOR_MOISTURE, key=SENSOR_MOISTURE,
device_class=SENSOR_MOISTURE, device_class=SENSOR_MOISTURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SENSOR_LIGHT: SensorEntityDescription( SENSOR_LIGHT: SensorEntityDescription(
key=SENSOR_LIGHT, key=SENSOR_LIGHT,
device_class=DEVICE_CLASS_ILLUMINANCE, device_class=SensorDeviceClass.ILLUMINANCE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
} }