Use enum sensor device class in AirVisual (#83316)

This commit is contained in:
Franck Nijhof 2022-12-05 17:24:47 +01:00 committed by GitHub
parent b97f95efc4
commit 150e49f4c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 25 deletions

View file

@ -43,9 +43,6 @@ ATTR_POLLUTANT_SYMBOL = "pollutant_symbol"
ATTR_POLLUTANT_UNIT = "pollutant_unit"
ATTR_REGION = "region"
DEVICE_CLASS_POLLUTANT_LABEL = "airvisual__pollutant_label"
DEVICE_CLASS_POLLUTANT_LEVEL = "airvisual__pollutant_level"
SENSOR_KIND_AQI = "air_quality_index"
SENSOR_KIND_BATTERY_LEVEL = "battery_level"
SENSOR_KIND_CO2 = "carbon_dioxide"
@ -63,8 +60,17 @@ GEOGRAPHY_SENSOR_DESCRIPTIONS = (
SensorEntityDescription(
key=SENSOR_KIND_LEVEL,
name="Air pollution level",
device_class=DEVICE_CLASS_POLLUTANT_LEVEL,
icon="mdi:gauge",
device_class=SensorDeviceClass.ENUM,
options=[
"good",
"moderate",
"unhealthy",
"unhealthy_sensitive",
"very_unhealthy",
"hazardous",
],
translation_key="pollutant_level",
),
SensorEntityDescription(
key=SENSOR_KIND_AQI,
@ -76,8 +82,10 @@ GEOGRAPHY_SENSOR_DESCRIPTIONS = (
SensorEntityDescription(
key=SENSOR_KIND_POLLUTANT,
name="Main pollutant",
device_class=DEVICE_CLASS_POLLUTANT_LABEL,
icon="mdi:chemical-weapon",
device_class=SensorDeviceClass.ENUM,
options=["co", "n2", "o3", "p1", "p2", "s2"],
translation_key="pollutant_label",
),
)
GEOGRAPHY_SENSOR_LOCALES = {"cn": "Chinese", "us": "U.S."}

View file

@ -59,5 +59,29 @@
}
}
}
},
"entity": {
"sensor": {
"pollutant_label": {
"state": {
"co": "Carbon Monoxide",
"n2": "Nitrogen Dioxide",
"o3": "Ozone",
"p1": "PM10",
"p2": "PM2.5",
"s2": "Sulfur Dioxide"
}
},
"pollutant_level": {
"state": {
"good": "Good",
"moderate": "Moderate",
"unhealthy": "Unhealthy",
"unhealthy_sensitive": "Unhealthy for sensitive groups",
"very_unhealthy": "Very unhealthy",
"hazardous": "Hazardous"
}
}
}
}
}

View file

@ -1,20 +0,0 @@
{
"state": {
"airvisual__pollutant_label": {
"co": "Carbon Monoxide",
"n2": "Nitrogen Dioxide",
"o3": "Ozone",
"p1": "PM10",
"p2": "PM2.5",
"s2": "Sulfur Dioxide"
},
"airvisual__pollutant_level": {
"good": "Good",
"moderate": "Moderate",
"unhealthy": "Unhealthy",
"unhealthy_sensitive": "Unhealthy for sensitive groups",
"very_unhealthy": "Very unhealthy",
"hazardous": "Hazardous"
}
}
}

View file

@ -50,6 +50,30 @@
}
}
},
"entity": {
"sensor": {
"pollutant_label": {
"state": {
"co": "Carbon Monoxide",
"n2": "Nitrogen Dioxide",
"o3": "Ozone",
"p1": "PM10",
"p2": "PM2.5",
"s2": "Sulfur Dioxide"
}
},
"pollutant_level": {
"state": {
"good": "Good",
"hazardous": "Hazardous",
"moderate": "Moderate",
"unhealthy": "Unhealthy",
"unhealthy_sensitive": "Unhealthy for sensitive groups",
"very_unhealthy": "Very unhealthy"
}
}
}
},
"options": {
"step": {
"init": {