Add air quality sensors to Accuweather integration (#91516)

This commit is contained in:
Maciej Bieniek
2023-04-22 17:19:21 +02:00
committed by GitHub
parent 20a42c65cf
commit ee23d79a00
4 changed files with 173 additions and 50 deletions
@@ -15,34 +15,35 @@
"UnitType": 17
}
},
"Ozone": {
"Value": 32,
"Category": "Good",
"CategoryValue": 1
"AirQuality": {
"Value": 0,
"Category": "good",
"CategoryValue": 1,
"Type": "Ozone"
},
"Grass": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Mold": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Ragweed": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Tree": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"UVIndex": {
"Value": 5,
"Category": "Moderate",
"Category": "moderate",
"CategoryValue": 2
},
"TemperatureMin": {
@@ -214,34 +215,35 @@
"UnitType": 17
}
},
"Ozone": {
"Value": 39,
"Category": "Good",
"CategoryValue": 1
"AirQuality": {
"Value": 0,
"Category": "good",
"CategoryValue": 1,
"Type": "Ozone"
},
"Grass": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Mold": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Ragweed": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Tree": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"UVIndex": {
"Value": 7,
"Category": "High",
"Category": "high",
"CategoryValue": 3
},
"TemperatureMin": {
@@ -409,34 +411,35 @@
"UnitType": 17
}
},
"Ozone": {
"Value": 29,
"Category": "Good",
"CategoryValue": 1
"AirQuality": {
"Value": 0,
"Category": "good",
"CategoryValue": 1,
"Type": "Ozone"
},
"Grass": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Mold": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Ragweed": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Tree": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"UVIndex": {
"Value": 7,
"Category": "High",
"Category": "high",
"CategoryValue": 3
},
"TemperatureMin": {
@@ -604,34 +607,35 @@
"UnitType": 17
}
},
"Ozone": {
"Value": 18,
"Category": "Good",
"CategoryValue": 1
"AirQuality": {
"Value": 0,
"Category": "good",
"CategoryValue": 1,
"Type": "Ozone"
},
"Grass": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Mold": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Ragweed": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Tree": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"UVIndex": {
"Value": 6,
"Category": "High",
"Category": "high",
"CategoryValue": 3
},
"TemperatureMin": {
@@ -799,34 +803,35 @@
"UnitType": 17
}
},
"Ozone": {
"Value": 14,
"Category": "Good",
"CategoryValue": 1
"AirQuality": {
"Value": 0,
"Category": "good",
"CategoryValue": 1,
"Type": "Ozone"
},
"Grass": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Mold": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Ragweed": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"Tree": {
"Value": 0,
"Category": "Low",
"Category": "low",
"CategoryValue": 1
},
"UVIndex": {
"Value": 7,
"Category": "High",
"Category": "high",
"CategoryValue": 3
},
"TemperatureMin": {
+24 -5
View File
@@ -189,13 +189,32 @@ async def test_sensor_with_forecast(hass: HomeAssistant) -> None:
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
assert state.attributes.get(ATTR_ICON) == "mdi:weather-sunny"
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UV_INDEX
assert state.attributes.get("level") == "Moderate"
assert state.attributes.get("level") == "moderate"
assert state.attributes.get(ATTR_STATE_CLASS) is None
entry = registry.async_get("sensor.home_uv_index_0d")
assert entry
assert entry.unique_id == "0123456-uvindex-0"
state = hass.states.get("sensor.home_air_quality_0d")
assert state
assert state.state == "good"
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
assert state.attributes.get(ATTR_ICON) == "mdi:air-filter"
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENUM
assert state.attributes.get(ATTR_OPTIONS) == [
"good",
"hazardous",
"high",
"low",
"moderate",
"unhealthy",
]
entry = registry.async_get("sensor.home_air_quality_0d")
assert entry
assert entry.unique_id == "0123456-airquality-0"
async def test_sensor_disabled(hass: HomeAssistant) -> None:
"""Test sensor disabled by default."""
@@ -499,7 +518,7 @@ async def test_sensor_enabled_without_forecast(hass: HomeAssistant) -> None:
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
== CONCENTRATION_PARTS_PER_CUBIC_METER
)
assert state.attributes.get("level") == "Low"
assert state.attributes.get("level") == "low"
assert state.attributes.get(ATTR_ICON) == "mdi:grass"
assert state.attributes.get(ATTR_STATE_CLASS) is None
@@ -515,7 +534,7 @@ async def test_sensor_enabled_without_forecast(hass: HomeAssistant) -> None:
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
== CONCENTRATION_PARTS_PER_CUBIC_METER
)
assert state.attributes.get("level") == "Low"
assert state.attributes.get("level") == "low"
assert state.attributes.get(ATTR_ICON) == "mdi:blur"
entry = registry.async_get("sensor.home_mold_pollen_0d")
@@ -530,7 +549,7 @@ async def test_sensor_enabled_without_forecast(hass: HomeAssistant) -> None:
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
== CONCENTRATION_PARTS_PER_CUBIC_METER
)
assert state.attributes.get("level") == "Low"
assert state.attributes.get("level") == "low"
assert state.attributes.get(ATTR_ICON) == "mdi:sprout"
entry = registry.async_get("sensor.home_ragweed_pollen_0d")
@@ -568,7 +587,7 @@ async def test_sensor_enabled_without_forecast(hass: HomeAssistant) -> None:
state.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
== CONCENTRATION_PARTS_PER_CUBIC_METER
)
assert state.attributes.get("level") == "Low"
assert state.attributes.get("level") == "low"
assert state.attributes.get(ATTR_ICON) == "mdi:tree-outline"
assert state.attributes.get(ATTR_STATE_CLASS) is None