mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 23:37:18 +00:00
Make AirNow use device class (#94986)
This commit is contained in:
parent
e4c8a94aaf
commit
c503becd9a
@ -6,6 +6,7 @@ from dataclasses import dataclass
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
@ -57,10 +58,9 @@ class AirNowEntityDescription(SensorEntityDescription, AirNowEntityDescriptionMi
|
|||||||
SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
|
||||||
AirNowEntityDescription(
|
AirNowEntityDescription(
|
||||||
key=ATTR_API_AQI,
|
key=ATTR_API_AQI,
|
||||||
translation_key="aqi",
|
|
||||||
icon="mdi:blur",
|
icon="mdi:blur",
|
||||||
native_unit_of_measurement="aqi",
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
device_class=SensorDeviceClass.AQI,
|
||||||
value_fn=lambda data: data.get(ATTR_API_AQI),
|
value_fn=lambda data: data.get(ATTR_API_AQI),
|
||||||
extra_state_attributes_fn=lambda data: {
|
extra_state_attributes_fn=lambda data: {
|
||||||
ATTR_DESCR: data[ATTR_API_AQI_DESCRIPTION],
|
ATTR_DESCR: data[ATTR_API_AQI_DESCRIPTION],
|
||||||
@ -69,10 +69,10 @@ SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
AirNowEntityDescription(
|
AirNowEntityDescription(
|
||||||
key=ATTR_API_PM25,
|
key=ATTR_API_PM25,
|
||||||
translation_key="pm25",
|
|
||||||
icon="mdi:blur",
|
icon="mdi:blur",
|
||||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
device_class=SensorDeviceClass.PM25,
|
||||||
value_fn=lambda data: data.get(ATTR_API_PM25),
|
value_fn=lambda data: data.get(ATTR_API_PM25),
|
||||||
extra_state_attributes_fn=None,
|
extra_state_attributes_fn=None,
|
||||||
),
|
),
|
||||||
|
@ -23,12 +23,6 @@
|
|||||||
},
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
"sensor": {
|
"sensor": {
|
||||||
"aqi": {
|
|
||||||
"name": "[%key:component::sensor::entity_component::aqi::name%]"
|
|
||||||
},
|
|
||||||
"pm25": {
|
|
||||||
"name": "[%key:component::sensor::entity_component::pm25::name%]"
|
|
||||||
},
|
|
||||||
"o3": {
|
"o3": {
|
||||||
"name": "[%key:component::sensor::entity_component::ozone::name%]"
|
"name": "[%key:component::sensor::entity_component::ozone::name%]"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user