mirror of
https://github.com/home-assistant/core.git
synced 2025-05-01 12:47:53 +00:00
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.
This commit is contained in:
parent
27b48573ea
commit
69461f115d
@ -2,7 +2,7 @@
|
|||||||
"domain": "environment_canada",
|
"domain": "environment_canada",
|
||||||
"name": "Environment Canada",
|
"name": "Environment Canada",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/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"],
|
"codeowners": ["@gwww", "@michaeldavie"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"iot_class": "cloud_polling",
|
"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(
|
AQHI_SENSOR = ECSensorEntityDescription(
|
||||||
key="aqhi",
|
key="aqhi",
|
||||||
name="AQHI",
|
name="AQHI",
|
||||||
device_class=SensorDeviceClass.AQI,
|
device_class=SensorDeviceClass.AQI,
|
||||||
native_unit_of_measurement="AQI",
|
native_unit_of_measurement="AQI",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
value_fn=lambda data: data.current,
|
value_fn=_get_aqhi_value,
|
||||||
)
|
)
|
||||||
|
|
||||||
ALERT_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
ALERT_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
||||||
|
@ -593,7 +593,7 @@ enocean==0.50
|
|||||||
enturclient==0.2.3
|
enturclient==0.2.3
|
||||||
|
|
||||||
# homeassistant.components.environment_canada
|
# homeassistant.components.environment_canada
|
||||||
env_canada==0.5.20
|
env_canada==0.5.21
|
||||||
|
|
||||||
# homeassistant.components.enphase_envoy
|
# homeassistant.components.enphase_envoy
|
||||||
envoy_reader==0.20.1
|
envoy_reader==0.20.1
|
||||||
|
@ -421,7 +421,7 @@ emulated_roku==0.2.1
|
|||||||
enocean==0.50
|
enocean==0.50
|
||||||
|
|
||||||
# homeassistant.components.environment_canada
|
# homeassistant.components.environment_canada
|
||||||
env_canada==0.5.20
|
env_canada==0.5.21
|
||||||
|
|
||||||
# homeassistant.components.enphase_envoy
|
# homeassistant.components.enphase_envoy
|
||||||
envoy_reader==0.20.1
|
envoy_reader==0.20.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user