Use new DeviceClass and StateClass enums in ambee (#61264)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/61279/head
epenet 2021-12-08 21:13:59 +01:00 committed by GitHub
parent 549b72e48e
commit c1a09d2bac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 27 deletions

View File

@ -6,15 +6,15 @@ import logging
from typing import Final from typing import Final
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT, SensorDeviceClass,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass,
) )
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEVICE_CLASS_CO,
) )
DOMAIN: Final = "ambee" DOMAIN: Final = "ambee"
@ -37,43 +37,43 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="particulate_matter_2_5", key="particulate_matter_2_5",
name="Particulate Matter < 2.5 μm", name="Particulate Matter < 2.5 μm",
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,
), ),
SensorEntityDescription( SensorEntityDescription(
key="particulate_matter_10", key="particulate_matter_10",
name="Particulate Matter < 10 μm", name="Particulate Matter < 10 μm",
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,
), ),
SensorEntityDescription( SensorEntityDescription(
key="sulphur_dioxide", key="sulphur_dioxide",
name="Sulphur Dioxide (SO2)", name="Sulphur Dioxide (SO2)",
native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="nitrogen_dioxide", key="nitrogen_dioxide",
name="Nitrogen Dioxide (NO2)", name="Nitrogen Dioxide (NO2)",
native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="ozone", key="ozone",
name="Ozone", name="Ozone",
native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="carbon_monoxide", key="carbon_monoxide",
name="Carbon Monoxide (CO)", name="Carbon Monoxide (CO)",
device_class=DEVICE_CLASS_CO, device_class=SensorDeviceClass.CO,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="air_quality_index", key="air_quality_index",
name="Air Quality Index (AQI)", name="Air Quality Index (AQI)",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
], ],
SERVICE_POLLEN: [ SERVICE_POLLEN: [
@ -81,21 +81,21 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="grass", key="grass",
name="Grass Pollen", name="Grass Pollen",
icon="mdi:grass", icon="mdi:grass",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
), ),
SensorEntityDescription( SensorEntityDescription(
key="tree", key="tree",
name="Tree Pollen", name="Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
), ),
SensorEntityDescription( SensorEntityDescription(
key="weed", key="weed",
name="Weed Pollen", name="Weed Pollen",
icon="mdi:sprout", icon="mdi:sprout",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
), ),
SensorEntityDescription( SensorEntityDescription(
@ -120,7 +120,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="grass_poaceae", key="grass_poaceae",
name="Poaceae Grass Pollen", name="Poaceae Grass Pollen",
icon="mdi:grass", icon="mdi:grass",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -128,7 +128,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="tree_alder", key="tree_alder",
name="Alder Tree Pollen", name="Alder Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -136,7 +136,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="tree_birch", key="tree_birch",
name="Birch Tree Pollen", name="Birch Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -144,7 +144,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="tree_cypress", key="tree_cypress",
name="Cypress Tree Pollen", name="Cypress Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -152,7 +152,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="tree_elm", key="tree_elm",
name="Elm Tree Pollen", name="Elm Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -160,7 +160,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="tree_hazel", key="tree_hazel",
name="Hazel Tree Pollen", name="Hazel Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -168,7 +168,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="tree_oak", key="tree_oak",
name="Oak Tree Pollen", name="Oak Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -176,7 +176,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="tree_pine", key="tree_pine",
name="Pine Tree Pollen", name="Pine Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -184,7 +184,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="tree_plane", key="tree_plane",
name="Plane Tree Pollen", name="Plane Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -192,7 +192,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="tree_poplar", key="tree_poplar",
name="Poplar Tree Pollen", name="Poplar Tree Pollen",
icon="mdi:tree", icon="mdi:tree",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -200,7 +200,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="weed_chenopod", key="weed_chenopod",
name="Chenopod Weed Pollen", name="Chenopod Weed Pollen",
icon="mdi:sprout", icon="mdi:sprout",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -208,7 +208,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="weed_mugwort", key="weed_mugwort",
name="Mugwort Weed Pollen", name="Mugwort Weed Pollen",
icon="mdi:sprout", icon="mdi:sprout",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -216,7 +216,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="weed_nettle", key="weed_nettle",
name="Nettle Weed Pollen", name="Nettle Weed Pollen",
icon="mdi:sprout", icon="mdi:sprout",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
@ -224,7 +224,7 @@ SENSORS: dict[str, list[SensorEntityDescription]] = {
key="weed_ragweed", key="weed_ragweed",
name="Ragweed Weed Pollen", name="Ragweed Weed Pollen",
icon="mdi:sprout", icon="mdi:sprout",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_PARTS_PER_CUBIC_METER,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),