Use state class enum in Mill (#60726)

This commit is contained in:
Daniel Hjelseth Høyer 2021-12-01 17:53:04 +01:00 committed by GitHub
parent 64a4218a24
commit 30e573b694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,11 +4,10 @@ from __future__ import annotations
import mill import mill
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorDeviceClass, SensorDeviceClass,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass,
) )
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_BILLION,
@ -43,14 +42,14 @@ HEATER_SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key=CONSUMPTION_YEAR, key=CONSUMPTION_YEAR,
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
name="Year consumption", name="Year consumption",
), ),
SensorEntityDescription( SensorEntityDescription(
key=CONSUMPTION_TODAY, key=CONSUMPTION_TODAY,
device_class=SensorDeviceClass.ENERGY, device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
name="Day consumption", name="Day consumption",
), ),
) )
@ -61,21 +60,21 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
name="Temperature", name="Temperature",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=HUMIDITY, key=HUMIDITY,
device_class=SensorDeviceClass.HUMIDITY, device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
name="Humidity", name="Humidity",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=BATTERY, key=BATTERY,
device_class=SensorDeviceClass.BATTERY, device_class=SensorDeviceClass.BATTERY,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
name="Battery", name="Battery",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
), ),
SensorEntityDescription( SensorEntityDescription(
@ -88,7 +87,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key=TVOC, key=TVOC,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION,
name="TVOC", name="TVOC",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
) )