Skip to content

Commit

Permalink
Add PM10 sensor to AirNow (#117432)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiyo committed May 14, 2024
1 parent 7f3d6fe commit b6a530c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions homeassistant/components/airnow/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ATTR_API_CAT_LEVEL = "Number"
ATTR_API_CAT_DESCRIPTION = "Name"
ATTR_API_O3 = "O3"
ATTR_API_PM10 = "PM10"
ATTR_API_PM25 = "PM2.5"
ATTR_API_POLLUTANT = "Pollutant"
ATTR_API_REPORT_DATE = "DateObserved"
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/airnow/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"aqi": {
"default": "mdi:blur"
},
"pm10": {
"default": "mdi:blur"
},
"pm25": {
"default": "mdi:blur"
},
Expand Down
10 changes: 10 additions & 0 deletions homeassistant/components/airnow/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
ATTR_API_AQI_DESCRIPTION,
ATTR_API_AQI_LEVEL,
ATTR_API_O3,
ATTR_API_PM10,
ATTR_API_PM25,
ATTR_API_REPORT_DATE,
ATTR_API_REPORT_HOUR,
Expand Down Expand Up @@ -87,6 +88,15 @@ def station_extra_attrs(data: dict[str, Any]) -> dict[str, Any]:
.isoformat(),
},
),
AirNowEntityDescription(
key=ATTR_API_PM10,
translation_key="pm10",
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.PM10,
value_fn=lambda data: data.get(ATTR_API_PM10),
extra_state_attributes_fn=None,
),
AirNowEntityDescription(
key=ATTR_API_PM25,
translation_key="pm25",
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/airnow/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"name": "[%key:component::sensor::entity_component::ozone::name%]"
},
"station": {
"name": "PM2.5 reporting station",
"name": "Reporting station",
"state_attributes": {
"lat": { "name": "[%key:common::config_flow::data::latitude%]" },
"long": { "name": "[%key:common::config_flow::data::longitude%]" }
Expand Down

0 comments on commit b6a530c

Please sign in to comment.