Environment Canada: allow AQHI to pull from forecast when current not available (#69142)
* Allow AQHI to pull from forecast when current not available. * Remove redundant check. * Remove lambda.pull/57491/head
parent
27b48573ea
commit
69461f115d
|
@ -2,7 +2,7 @@
|
|||
"domain": "environment_canada",
|
||||
"name": "Environment Canada",
|
||||
"documentation": "https://www.home-assistant.io/integrations/environment_canada",
|
||||
"requirements": ["env_canada==0.5.20"],
|
||||
"requirements": ["env_canada==0.5.21"],
|
||||
"codeowners": ["@gwww", "@michaeldavie"],
|
||||
"config_flow": true,
|
||||
"iot_class": "cloud_polling",
|
||||
|
|
|
@ -209,13 +209,23 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
),
|
||||
)
|
||||
|
||||
|
||||
def _get_aqhi_value(data):
|
||||
if (aqhi := data.current) is not None:
|
||||
return aqhi
|
||||
if data.forecasts and (hourly := data.forecasts.get("hourly")) is not None:
|
||||
if values := list(hourly.values()):
|
||||
return values[0]
|
||||
return None
|
||||
|
||||
|
||||
AQHI_SENSOR = ECSensorEntityDescription(
|
||||
key="aqhi",
|
||||
name="AQHI",
|
||||
device_class=SensorDeviceClass.AQI,
|
||||
native_unit_of_measurement="AQI",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.current,
|
||||
value_fn=_get_aqhi_value,
|
||||
)
|
||||
|
||||
ALERT_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
||||
|
|
|
@ -593,7 +593,7 @@ enocean==0.50
|
|||
enturclient==0.2.3
|
||||
|
||||
# homeassistant.components.environment_canada
|
||||
env_canada==0.5.20
|
||||
env_canada==0.5.21
|
||||
|
||||
# homeassistant.components.enphase_envoy
|
||||
envoy_reader==0.20.1
|
||||
|
|
|
@ -421,7 +421,7 @@ emulated_roku==0.2.1
|
|||
enocean==0.50
|
||||
|
||||
# homeassistant.components.environment_canada
|
||||
env_canada==0.5.20
|
||||
env_canada==0.5.21
|
||||
|
||||
# homeassistant.components.enphase_envoy
|
||||
envoy_reader==0.20.1
|
||||
|
|
Loading…
Reference in New Issue