Add AirNow Reporting Station as sensor (#97273)

* Add AirNow Reporting Station as sensor attribute

* Make Reporting Station a sensor instead of attribute as requested

* Update homeassistant/components/airnow/strings.json

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Fix reporting station attribute names to avoid showing on map

* Add attribute name translations

* Update homeassistant/components/airnow/strings.json

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
This commit is contained in:
J.P. Krauss 2023-07-27 12:19:16 -07:00 committed by GitHub
parent 7e3fdd85fc
commit 70cb8afb94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -30,6 +30,9 @@ from .const import (
ATTR_API_AQI_LEVEL,
ATTR_API_O3,
ATTR_API_PM25,
ATTR_API_STATION,
ATTR_API_STATION_LATITUDE,
ATTR_API_STATION_LONGITUDE,
DEFAULT_NAME,
DOMAIN,
)
@ -40,6 +43,7 @@ PARALLEL_UPDATES = 1
ATTR_DESCR = "description"
ATTR_LEVEL = "level"
ATTR_STATION = "reporting_station"
@dataclass
@ -85,6 +89,16 @@ SENSOR_TYPES: tuple[AirNowEntityDescription, ...] = (
value_fn=lambda data: data.get(ATTR_API_O3),
extra_state_attributes_fn=None,
),
AirNowEntityDescription(
key=ATTR_API_STATION,
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],
},
),
)