mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Use new DeviceClass and StateClass enums in airly (#61258)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
25224f6945
commit
048bdd321e
@ -6,22 +6,16 @@ from dataclasses import dataclass
|
|||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
ATTR_ATTRIBUTION,
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
DEVICE_CLASS_AQI,
|
|
||||||
DEVICE_CLASS_HUMIDITY,
|
|
||||||
DEVICE_CLASS_PM1,
|
|
||||||
DEVICE_CLASS_PM10,
|
|
||||||
DEVICE_CLASS_PM25,
|
|
||||||
DEVICE_CLASS_PRESSURE,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
PRESSURE_HPA,
|
PRESSURE_HPA,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
@ -72,52 +66,52 @@ class AirlySensorEntityDescription(SensorEntityDescription):
|
|||||||
SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[AirlySensorEntityDescription, ...] = (
|
||||||
AirlySensorEntityDescription(
|
AirlySensorEntityDescription(
|
||||||
key=ATTR_API_CAQI,
|
key=ATTR_API_CAQI,
|
||||||
device_class=DEVICE_CLASS_AQI,
|
device_class=SensorDeviceClass.AQI,
|
||||||
name=ATTR_API_CAQI,
|
name=ATTR_API_CAQI,
|
||||||
native_unit_of_measurement="CAQI",
|
native_unit_of_measurement="CAQI",
|
||||||
),
|
),
|
||||||
AirlySensorEntityDescription(
|
AirlySensorEntityDescription(
|
||||||
key=ATTR_API_PM1,
|
key=ATTR_API_PM1,
|
||||||
device_class=DEVICE_CLASS_PM1,
|
device_class=SensorDeviceClass.PM1,
|
||||||
name=ATTR_API_PM1,
|
name=ATTR_API_PM1,
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
AirlySensorEntityDescription(
|
AirlySensorEntityDescription(
|
||||||
key=ATTR_API_PM25,
|
key=ATTR_API_PM25,
|
||||||
device_class=DEVICE_CLASS_PM25,
|
device_class=SensorDeviceClass.PM25,
|
||||||
name="PM2.5",
|
name="PM2.5",
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
AirlySensorEntityDescription(
|
AirlySensorEntityDescription(
|
||||||
key=ATTR_API_PM10,
|
key=ATTR_API_PM10,
|
||||||
device_class=DEVICE_CLASS_PM10,
|
device_class=SensorDeviceClass.PM10,
|
||||||
name=ATTR_API_PM10,
|
name=ATTR_API_PM10,
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
AirlySensorEntityDescription(
|
AirlySensorEntityDescription(
|
||||||
key=ATTR_API_HUMIDITY,
|
key=ATTR_API_HUMIDITY,
|
||||||
device_class=DEVICE_CLASS_HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
name=ATTR_API_HUMIDITY.capitalize(),
|
name=ATTR_API_HUMIDITY.capitalize(),
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value=lambda value: round(value, 1),
|
value=lambda value: round(value, 1),
|
||||||
),
|
),
|
||||||
AirlySensorEntityDescription(
|
AirlySensorEntityDescription(
|
||||||
key=ATTR_API_PRESSURE,
|
key=ATTR_API_PRESSURE,
|
||||||
device_class=DEVICE_CLASS_PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
name=ATTR_API_PRESSURE.capitalize(),
|
name=ATTR_API_PRESSURE.capitalize(),
|
||||||
native_unit_of_measurement=PRESSURE_HPA,
|
native_unit_of_measurement=PRESSURE_HPA,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
AirlySensorEntityDescription(
|
AirlySensorEntityDescription(
|
||||||
key=ATTR_API_TEMPERATURE,
|
key=ATTR_API_TEMPERATURE,
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
name=ATTR_API_TEMPERATURE.capitalize(),
|
name=ATTR_API_TEMPERATURE.capitalize(),
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value=lambda value: round(value, 1),
|
value=lambda value: round(value, 1),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user