Fix error is measurement is not sent by AirNow (#100477)
This commit is contained in:
parent
c8265a86b2
commit
01ecef7f05
1 changed files with 11 additions and 4 deletions
|
@ -58,6 +58,16 @@ class AirNowEntityDescription(SensorEntityDescription, AirNowEntityDescriptionMi
|
|||
"""Describes Airnow sensor entity."""
|
||||
|
||||
|
||||
def station_extra_attrs(data: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Process extra attributes for station location (if available)."""
|
||||
if ATTR_API_STATION in data:
|
||||
return {
|
||||
"lat": data.get(ATTR_API_STATION_LATITUDE),
|
||||
"long": data.get(ATTR_API_STATION_LONGITUDE),
|
||||
}
|
||||
return {}
|
||||
|
||||
|
||||
SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
|
||||
AirNowEntityDescription(
|
||||
key=ATTR_API_AQI,
|
||||
|
@ -93,10 +103,7 @@ SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
|
|||
translation_key="station",
|
||||
icon="mdi:blur",
|
||||
value_fn=lambda data: data.get(ATTR_API_STATION),
|
||||
extra_state_attributes_fn=lambda data: {
|
||||
"lat": data[ATTR_API_STATION_LATITUDE],
|
||||
"long": data[ATTR_API_STATION_LONGITUDE],
|
||||
},
|
||||
extra_state_attributes_fn=station_extra_attrs,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue