Use SensorDeviceClass in mhz19 (#61923)

This commit is contained in:
epenet 2021-12-15 20:11:06 +01:00 committed by GitHub
parent b42e2e6ef0
commit 2da2de2ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ import voluptuous as vol
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
SensorDeviceClass,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
) )
@ -17,8 +18,6 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
CONF_MONITORED_CONDITIONS, CONF_MONITORED_CONDITIONS,
CONF_NAME, CONF_NAME,
DEVICE_CLASS_CO2,
DEVICE_CLASS_TEMPERATURE,
TEMP_CELSIUS, TEMP_CELSIUS,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -40,13 +39,13 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key=SENSOR_TEMPERATURE, key=SENSOR_TEMPERATURE,
name="Temperature", name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),
SensorEntityDescription( SensorEntityDescription(
key=SENSOR_CO2, key=SENSOR_CO2,
name="CO2", name="CO2",
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
device_class=DEVICE_CLASS_CO2, device_class=SensorDeviceClass.CO2,
), ),
) )
SENSOR_KEYS: list[str] = [desc.key for desc in SENSOR_TYPES] SENSOR_KEYS: list[str] = [desc.key for desc in SENSOR_TYPES]