Use enum sensor device class in Tomorrow.io (#83293)

This commit is contained in:
Franck Nijhof 2022-12-05 13:17:49 +01:00 committed by GitHub
parent 2602b45ec8
commit 226a880645
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 98 additions and 33 deletions

View File

@ -169,7 +169,9 @@ SENSOR_TYPES = (
key=TMRW_ATTR_PRECIPITATION_TYPE,
name="Precipitation Type",
value_map=PrecipitationType,
device_class="tomorrowio__precipitation_type",
device_class=SensorDeviceClass.ENUM,
options=["freezing_rain", "ice_pellets", "none", "rain", "snow"],
translation_key="precipitation_type",
icon="mdi:weather-snowy-rainy",
),
# Data comes in as ppb, convert to µg/m^3
@ -233,7 +235,16 @@ SENSOR_TYPES = (
key=TMRW_ATTR_EPA_HEALTH_CONCERN,
name="US EPA Health Concern",
value_map=HealthConcernType,
device_class="tomorrowio__health_concern",
device_class=SensorDeviceClass.ENUM,
options=[
"good",
"hazardous",
"moderate",
"unhealthy_for_sensitive_groups",
"unhealthy",
"very_unhealthy",
],
translation_key="health_concern",
icon="mdi:hospital",
),
TomorrowioSensorEntityDescription(
@ -250,28 +261,43 @@ SENSOR_TYPES = (
key=TMRW_ATTR_CHINA_HEALTH_CONCERN,
name="China MEP Health Concern",
value_map=HealthConcernType,
device_class="tomorrowio__health_concern",
device_class=SensorDeviceClass.ENUM,
options=[
"good",
"hazardous",
"moderate",
"unhealthy_for_sensitive_groups",
"unhealthy",
"very_unhealthy",
],
translation_key="health_concern",
icon="mdi:hospital",
),
TomorrowioSensorEntityDescription(
key=TMRW_ATTR_POLLEN_TREE,
name="Tree Pollen Index",
value_map=PollenIndex,
device_class="tomorrowio__pollen_index",
device_class=SensorDeviceClass.ENUM,
options=["high", "low", "medium", "none", "very_high", "very_low"],
translation_key="pollen_index",
icon="mdi:flower-pollen",
),
TomorrowioSensorEntityDescription(
key=TMRW_ATTR_POLLEN_WEED,
name="Weed Pollen Index",
value_map=PollenIndex,
device_class="tomorrowio__pollen_index",
device_class=SensorDeviceClass.ENUM,
options=["high", "low", "medium", "none", "very_high", "very_low"],
translation_key="pollen_index",
icon="mdi:flower-pollen",
),
TomorrowioSensorEntityDescription(
key=TMRW_ATTR_POLLEN_GRASS,
name="Grass Pollen Index",
value_map=PollenIndex,
device_class="tomorrowio__pollen_index",
device_class=SensorDeviceClass.ENUM,
options=["high", "low", "medium", "none", "very_high", "very_low"],
translation_key="pollen_index",
icon="mdi:flower-pollen",
),
TomorrowioSensorEntityDescription(

View File

@ -27,5 +27,38 @@
}
}
}
},
"entity": {
"sensor": {
"health_concern": {
"state": {
"good": "Good",
"moderate": "Moderate",
"unhealthy_for_sensitive_groups": "Unhealthy for Sensitive Groups",
"unhealthy": "Unhealthy",
"very_unhealthy": "Very Unhealthy",
"hazardous": "Hazardous"
}
},
"pollen_index": {
"state": {
"none": "None",
"very_low": "Very Low",
"low": "Low",
"medium": "Medium",
"high": "High",
"very_high": "Very High"
}
},
"precipitation_type": {
"state": {
"none": "None",
"rain": "Rain",
"snow": "Snow",
"freezing_rain": "Freezing Rain",
"ice_pellets": "Ice Pellets"
}
}
}
}
}

View File

@ -1,27 +0,0 @@
{
"state": {
"tomorrowio__pollen_index": {
"none": "None",
"very_low": "Very Low",
"low": "Low",
"medium": "Medium",
"high": "High",
"very_high": "Very High"
},
"tomorrowio__health_concern": {
"good": "Good",
"moderate": "Moderate",
"unhealthy_for_sensitive_groups": "Unhealthy for Sensitive Groups",
"unhealthy": "Unhealthy",
"very_unhealthy": "Very Unhealthy",
"hazardous": "Hazardous"
},
"tomorrowio__precipitation_type": {
"none": "None",
"rain": "Rain",
"snow": "Snow",
"freezing_rain": "Freezing Rain",
"ice_pellets": "Ice Pellets"
}
}
}

View File

@ -17,6 +17,39 @@
}
}
},
"entity": {
"sensor": {
"health_concern": {
"state": {
"good": "Good",
"hazardous": "Hazardous",
"moderate": "Moderate",
"unhealthy": "Unhealthy",
"unhealthy_for_sensitive_groups": "Unhealthy for Sensitive Groups",
"very_unhealthy": "Very Unhealthy"
}
},
"pollen_index": {
"state": {
"high": "High",
"low": "Low",
"medium": "Medium",
"none": "None",
"very_high": "Very High",
"very_low": "Very Low"
}
},
"precipitation_type": {
"state": {
"freezing_rain": "Freezing Rain",
"ice_pellets": "Ice Pellets",
"none": "None",
"rain": "Rain",
"snow": "Snow"
}
}
}
},
"options": {
"step": {
"init": {