Add long-term statistics for AirNow sensors (#56230)

This commit is contained in:
Aaron Bach 2021-09-14 14:04:55 -06:00 committed by GitHub
parent 2a51bb5bba
commit 0364922d80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,11 @@
"""Support for the AirNow sensor service.""" """Support for the AirNow sensor service."""
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.const import ( from homeassistant.const import (
ATTR_ATTRIBUTION, ATTR_ATTRIBUTION,
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
@ -31,18 +35,21 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
icon="mdi:blur", icon="mdi:blur",
name=ATTR_API_AQI, name=ATTR_API_AQI,
native_unit_of_measurement="aqi", native_unit_of_measurement="aqi",
state_class=STATE_CLASS_MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=ATTR_API_PM25, key=ATTR_API_PM25,
icon="mdi:blur", icon="mdi:blur",
name=ATTR_API_PM25, name=ATTR_API_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=ATTR_API_O3, key=ATTR_API_O3,
icon="mdi:blur", icon="mdi:blur",
name=ATTR_API_O3, name=ATTR_API_O3,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=STATE_CLASS_MEASUREMENT,
), ),
) )