Add value map for Climacell V3 pollen sensors (#50200)

This commit is contained in:
Raman Gupta 2021-05-07 00:12:51 -04:00 committed by GitHub
parent 7b07bc2d65
commit 9f1b1c6c56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 10 deletions

View File

@ -6,6 +6,7 @@ from pyclimacell.const import (
HealthConcernType,
PollenIndex,
PrimaryPollutantType,
V3PollenIndex,
WeatherCode,
)
@ -307,8 +308,20 @@ CC_V3_SENSOR_TYPES = [
ATTR_FIELD: CC_V3_ATTR_CHINA_HEALTH_CONCERN,
ATTR_NAME: "China MEP Health Concern",
},
{ATTR_FIELD: CC_V3_ATTR_POLLEN_TREE, ATTR_NAME: "Tree Pollen Index"},
{ATTR_FIELD: CC_V3_ATTR_POLLEN_WEED, ATTR_NAME: "Weed Pollen Index"},
{ATTR_FIELD: CC_V3_ATTR_POLLEN_GRASS, ATTR_NAME: "Grass Pollen Index"},
{
ATTR_FIELD: CC_V3_ATTR_POLLEN_TREE,
ATTR_NAME: "Tree Pollen Index",
ATTR_VALUE_MAP: V3PollenIndex,
},
{
ATTR_FIELD: CC_V3_ATTR_POLLEN_WEED,
ATTR_NAME: "Weed Pollen Index",
ATTR_VALUE_MAP: V3PollenIndex,
},
{
ATTR_FIELD: CC_V3_ATTR_POLLEN_GRASS,
ATTR_NAME: "Grass Pollen Index",
ATTR_VALUE_MAP: V3PollenIndex,
},
{ATTR_FIELD: CC_V3_ATTR_FIRE_INDEX, ATTR_NAME: "Fire Index"},
]

View File

@ -3,7 +3,7 @@
"name": "ClimaCell",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/climacell",
"requirements": ["pyclimacell==0.18.0"],
"requirements": ["pyclimacell==0.18.2"],
"codeowners": ["@raman325"],
"iot_class": "cloud_polling"
}

View File

@ -128,7 +128,7 @@ class BaseClimaCellSensorEntity(ClimaCellEntity, SensorEntity):
):
return round(self._state * self.sensor_type[ATTR_METRIC_CONVERSION], 4)
if ATTR_VALUE_MAP in self.sensor_type:
if ATTR_VALUE_MAP in self.sensor_type and self._state is not None:
return self.sensor_type[ATTR_VALUE_MAP](self._state).name.lower()
return self._state

View File

@ -1319,7 +1319,7 @@ pychromecast==9.1.2
pycketcasts==1.0.0
# homeassistant.components.climacell
pyclimacell==0.18.0
pyclimacell==0.18.2
# homeassistant.components.cmus
pycmus==0.1.1

View File

@ -720,7 +720,7 @@ pycfdns==1.2.1
pychromecast==9.1.2
# homeassistant.components.climacell
pyclimacell==0.18.0
pyclimacell==0.18.2
# homeassistant.components.comfoconnect
pycomfoconnect==0.4

View File

@ -119,9 +119,9 @@ async def test_v3_sensor(
check_sensor_state(hass, EPA_HEALTH_CONCERN, "Good")
check_sensor_state(hass, EPA_PRIMARY_POLLUTANT, "pm25")
check_sensor_state(hass, FIRE_INDEX, "9")
check_sensor_state(hass, GRASS_POLLEN, "0")
check_sensor_state(hass, WEED_POLLEN, "0")
check_sensor_state(hass, TREE_POLLEN, "0")
check_sensor_state(hass, GRASS_POLLEN, "minimal_to_none")
check_sensor_state(hass, WEED_POLLEN, "minimal_to_none")
check_sensor_state(hass, TREE_POLLEN, "minimal_to_none")
async def test_v4_sensor(