Use enum sensor device class in AirVisual (#83316)
This commit is contained in:
parent
b97f95efc4
commit
150e49f4c2
4 changed files with 61 additions and 25 deletions
|
@ -43,9 +43,6 @@ ATTR_POLLUTANT_SYMBOL = "pollutant_symbol"
|
||||||
ATTR_POLLUTANT_UNIT = "pollutant_unit"
|
ATTR_POLLUTANT_UNIT = "pollutant_unit"
|
||||||
ATTR_REGION = "region"
|
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_AQI = "air_quality_index"
|
||||||
SENSOR_KIND_BATTERY_LEVEL = "battery_level"
|
SENSOR_KIND_BATTERY_LEVEL = "battery_level"
|
||||||
SENSOR_KIND_CO2 = "carbon_dioxide"
|
SENSOR_KIND_CO2 = "carbon_dioxide"
|
||||||
|
@ -63,8 +60,17 @@ GEOGRAPHY_SENSOR_DESCRIPTIONS = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=SENSOR_KIND_LEVEL,
|
key=SENSOR_KIND_LEVEL,
|
||||||
name="Air pollution level",
|
name="Air pollution level",
|
||||||
device_class=DEVICE_CLASS_POLLUTANT_LEVEL,
|
|
||||||
icon="mdi:gauge",
|
icon="mdi:gauge",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=[
|
||||||
|
"good",
|
||||||
|
"moderate",
|
||||||
|
"unhealthy",
|
||||||
|
"unhealthy_sensitive",
|
||||||
|
"very_unhealthy",
|
||||||
|
"hazardous",
|
||||||
|
],
|
||||||
|
translation_key="pollutant_level",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=SENSOR_KIND_AQI,
|
key=SENSOR_KIND_AQI,
|
||||||
|
@ -76,8 +82,10 @@ GEOGRAPHY_SENSOR_DESCRIPTIONS = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=SENSOR_KIND_POLLUTANT,
|
key=SENSOR_KIND_POLLUTANT,
|
||||||
name="Main pollutant",
|
name="Main pollutant",
|
||||||
device_class=DEVICE_CLASS_POLLUTANT_LABEL,
|
|
||||||
icon="mdi:chemical-weapon",
|
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."}
|
GEOGRAPHY_SENSOR_LOCALES = {"cn": "Chinese", "us": "U.S."}
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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": {
|
"options": {
|
||||||
"step": {
|
"step": {
|
||||||
"init": {
|
"init": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue