Add long-term statistics for AirVisual sensors (#55415)

This commit is contained in:
Aaron Bach 2021-09-14 14:08:54 -06:00 committed by GitHub
parent 96a9af8cc4
commit 441e99b439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,11 @@
"""Support for AirVisual air quality sensors.""" """Support for AirVisual air quality sensors."""
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ATTR_LATITUDE, ATTR_LATITUDE,
@ -76,6 +80,7 @@ GEOGRAPHY_SENSOR_DESCRIPTIONS = (
name="Air Quality Index", name="Air Quality Index",
device_class=DEVICE_CLASS_AQI, device_class=DEVICE_CLASS_AQI,
native_unit_of_measurement="AQI", native_unit_of_measurement="AQI",
state_class=STATE_CLASS_MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=SENSOR_KIND_POLLUTANT, key=SENSOR_KIND_POLLUTANT,
@ -92,6 +97,7 @@ NODE_PRO_SENSOR_DESCRIPTIONS = (
name="Air Quality Index", name="Air Quality Index",
device_class=DEVICE_CLASS_AQI, device_class=DEVICE_CLASS_AQI,
native_unit_of_measurement="AQI", native_unit_of_measurement="AQI",
state_class=STATE_CLASS_MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=SENSOR_KIND_BATTERY_LEVEL, key=SENSOR_KIND_BATTERY_LEVEL,
@ -104,6 +110,7 @@ NODE_PRO_SENSOR_DESCRIPTIONS = (
name="C02", name="C02",
device_class=DEVICE_CLASS_CO2, device_class=DEVICE_CLASS_CO2,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=STATE_CLASS_MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=SENSOR_KIND_HUMIDITY, key=SENSOR_KIND_HUMIDITY,
@ -116,30 +123,35 @@ NODE_PRO_SENSOR_DESCRIPTIONS = (
name="PM 0.1", name="PM 0.1",
device_class=DEVICE_CLASS_PM1, device_class=DEVICE_CLASS_PM1,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=STATE_CLASS_MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=SENSOR_KIND_PM_1_0, key=SENSOR_KIND_PM_1_0,
name="PM 1.0", name="PM 1.0",
device_class=DEVICE_CLASS_PM10, device_class=DEVICE_CLASS_PM10,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=STATE_CLASS_MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=SENSOR_KIND_PM_2_5, key=SENSOR_KIND_PM_2_5,
name="PM 2.5", name="PM 2.5",
device_class=DEVICE_CLASS_PM25, device_class=DEVICE_CLASS_PM25,
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=STATE_CLASS_MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=SENSOR_KIND_TEMPERATURE, key=SENSOR_KIND_TEMPERATURE,
name="Temperature", name="Temperature",
device_class=DEVICE_CLASS_TEMPERATURE, device_class=DEVICE_CLASS_TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
state_class=STATE_CLASS_MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=SENSOR_KIND_VOC, key=SENSOR_KIND_VOC,
name="VOC", name="VOC",
device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=STATE_CLASS_MEASUREMENT,
), ),
) )