Make AirNow use device class (#94986)

This commit is contained in:
Joost Lekkerkerker 2023-06-22 15:58:14 +02:00 committed by GitHub
parent e4c8a94aaf
commit c503becd9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 9 deletions

View File

@ -6,6 +6,7 @@ from dataclasses import dataclass
from typing import Any
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
@ -57,10 +58,9 @@ class AirNowEntityDescription(SensorEntityDescription, AirNowEntityDescriptionMi
SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
AirNowEntityDescription(
key=ATTR_API_AQI,
translation_key="aqi",
icon="mdi:blur",
native_unit_of_measurement="aqi",
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.AQI,
value_fn=lambda data: data.get(ATTR_API_AQI),
extra_state_attributes_fn=lambda data: {
ATTR_DESCR: data[ATTR_API_AQI_DESCRIPTION],
@ -69,10 +69,10 @@ SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
),
AirNowEntityDescription(
key=ATTR_API_PM25,
translation_key="pm25",
icon="mdi:blur",
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.PM25,
value_fn=lambda data: data.get(ATTR_API_PM25),
extra_state_attributes_fn=None,
),

View File

@ -23,12 +23,6 @@
},
"entity": {
"sensor": {
"aqi": {
"name": "[%key:component::sensor::entity_component::aqi::name%]"
},
"pm25": {
"name": "[%key:component::sensor::entity_component::pm25::name%]"
},
"o3": {
"name": "[%key:component::sensor::entity_component::ozone::name%]"
}