mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Fix error is measurement is not sent by AirNow (#100477)
This commit is contained in:
parent
c8265a86b2
commit
01ecef7f05
@ -58,6 +58,16 @@ class AirNowEntityDescription(SensorEntityDescription, AirNowEntityDescriptionMi
|
|||||||
"""Describes Airnow sensor entity."""
|
"""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, ...] = (
|
SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
|
||||||
AirNowEntityDescription(
|
AirNowEntityDescription(
|
||||||
key=ATTR_API_AQI,
|
key=ATTR_API_AQI,
|
||||||
@ -93,10 +103,7 @@ SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
|
|||||||
translation_key="station",
|
translation_key="station",
|
||||||
icon="mdi:blur",
|
icon="mdi:blur",
|
||||||
value_fn=lambda data: data.get(ATTR_API_STATION),
|
value_fn=lambda data: data.get(ATTR_API_STATION),
|
||||||
extra_state_attributes_fn=lambda data: {
|
extra_state_attributes_fn=station_extra_attrs,
|
||||||
"lat": data[ATTR_API_STATION_LATITUDE],
|
|
||||||
"long": data[ATTR_API_STATION_LONGITUDE],
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user