mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 18:39:30 +00:00
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:
@@ -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],
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user