Use device class enum in Mill (#60699)

This commit is contained in:
Daniel Hjelseth Høyer 2021-12-01 10:58:28 +01:00 committed by GitHub
parent 49f3a7ce46
commit 06f12fc583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,13 +4,9 @@ from __future__ import annotations
import mill
from homeassistant.components.sensor import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CO2,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_TEMPERATURE,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
@ -45,14 +41,14 @@ from .const import (
HEATER_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key=CONSUMPTION_YEAR,
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
name="Year consumption",
),
SensorEntityDescription(
key=CONSUMPTION_TODAY,
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
name="Day consumption",
@ -62,21 +58,21 @@ HEATER_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key=TEMPERATURE,
device_class=DEVICE_CLASS_TEMPERATURE,
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS,
name="Temperature",
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key=HUMIDITY,
device_class=DEVICE_CLASS_HUMIDITY,
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=PERCENTAGE,
name="Humidity",
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key=BATTERY,
device_class=DEVICE_CLASS_BATTERY,
device_class=SensorDeviceClass.BATTERY,
native_unit_of_measurement=PERCENTAGE,
name="Battery",
state_class=STATE_CLASS_MEASUREMENT,
@ -84,7 +80,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
),
SensorEntityDescription(
key=ECO2,
device_class=DEVICE_CLASS_CO2,
device_class=SensorDeviceClass.CO2,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
name="Estimated CO2",
),