Airly
The Airly integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] uses the Airly web service as a source for air quality data for your location.
Use cases
- Get a notification with Airly’s advice when the air quality becomes poor.
- Turn on your air purifier or ventilation automatically when the particulate matter level rises.
- Get a reminder to keep your windows closed when the outdoor air is polluted.
- Show the current outdoor air quality on your dashboard.
- Track how the air quality changes over time in the history panel.
See Automation examples for examples you can use as a starting point.
Setup
To generate an Airly API key, go to Airly for developers page.
Configuration
To add the Airly service to your Home Assistant instance, use this My button:
Manual configuration steps
If the above My button doesn’t work, you can also perform the following steps manually:
-
Browse to your Home Assistant instance.
-
In the bottom right corner, select the
Add Integration button. -
From the list, select Airly.
-
Follow the instructions on screen to complete the setup.
The latitude of the location for which to retrieve air quality data. By default, Home Assistant uses your home location.
Supported functionality
The Airly integration provides the following entities. Which entities are created depends on the data available from the Airly measuring stations closest to your location.
Sensors
-
Common air quality index
-
Description: Shows the Common Air Quality Index (CAQI) for your location. The
level,description, andadviceattributes provide a human-readable air quality level and a recommendation from Airly.
-
Description: Shows the Common Air Quality Index (CAQI) for your location. The
-
PM1
- Description: Shows the concentration of particulate matter smaller than 1 micrometer in micrograms per cubic meter.
-
PM2.5
-
Description: Shows the concentration of particulate matter smaller than 2.5 micrometers in micrograms per cubic meter. The
limitandpercentattributes show the recommended limit and the measured value as a percentage of that limit.
-
Description: Shows the concentration of particulate matter smaller than 2.5 micrometers in micrograms per cubic meter. The
-
PM10
-
Description: Shows the concentration of particulate matter smaller than 10 micrometers in micrograms per cubic meter. The
limitandpercentattributes show the recommended limit and the measured value as a percentage of that limit.
-
Description: Shows the concentration of particulate matter smaller than 10 micrometers in micrograms per cubic meter. The
-
Carbon monoxide
-
Description: Shows the carbon monoxide concentration in micrograms per cubic meter. The
limitandpercentattributes show the recommended limit and the measured value as a percentage of that limit.
-
Description: Shows the carbon monoxide concentration in micrograms per cubic meter. The
-
Nitrogen dioxide
-
Description: Shows the nitrogen dioxide concentration in micrograms per cubic meter. The
limitandpercentattributes show the recommended limit and the measured value as a percentage of that limit.
-
Description: Shows the nitrogen dioxide concentration in micrograms per cubic meter. The
-
Ozone
-
Description: Shows the ozone concentration in micrograms per cubic meter. The
limitandpercentattributes show the recommended limit and the measured value as a percentage of that limit.
-
Description: Shows the ozone concentration in micrograms per cubic meter. The
-
Sulphur dioxide
-
Description: Shows the sulfur dioxide concentration in micrograms per cubic meter. The
limitandpercentattributes show the recommended limit and the measured value as a percentage of that limit.
-
Description: Shows the sulfur dioxide concentration in micrograms per cubic meter. The
-
Humidity
- Description: Shows the relative humidity in percent.
-
Pressure
- Description: Shows the atmospheric pressure in hectopascals.
-
Temperature
- Description: Shows the air temperature in degrees Celsius.
Automation examples
The following examples show how to use the integration in Home Assistant automations. These examples are just a starting point, and you can use them as inspiration to create your own automations.
You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the visual automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.
Automation: notify when the air quality is poor
This automation sends a notification when the common air quality index goes above 75, which is where the index enters the “high” range. The message includes the current index value and the advice provided by Airly.
In the automation editor:
-
Trigger: Numeric state crossed threshold
-
Entity: Common air quality index (
sensor.airly_common_air_quality_index) -
Above:
75
-
Entity: Common air quality index (
-
Action: Send a notification message
-
Target: My Device (
notify.my_device) -
Title:
Poor air quality - Message: The current index value and the advice from Airly
-
Target: My Device (
YAML example for notifying when the air quality is poor
alias: "Notify when the air quality is poor"
triggers:
- trigger: numeric_state
entity_id: sensor.airly_common_air_quality_index
above: 75
actions:
- action: notify.send_message
target:
entity_id: notify.my_device
data:
title: "Poor air quality"
message: >
The air quality index is
{{ states('sensor.airly_common_air_quality_index') }}.
{{ state_attr('sensor.airly_common_air_quality_index', 'advice') }}
Automation: control an air purifier based on the PM2.5 level
These two automations turn on an air purifier when the PM2.5 level goes above 25 µg/m³ and turn it off when the level drops below 15 µg/m³. Using two different thresholds keeps the purifier from turning on and off repeatedly when the level hovers around a single threshold.
In the automation editor, create the first automation:
-
Trigger: Numeric state crossed threshold
-
Entity: PM2.5 (
sensor.airly_pm2_5) -
Above:
25
-
Entity: PM2.5 (
-
Action: Turn on fan
-
Target: Air purifier (
fan.air_purifier)
-
Target: Air purifier (
YAML example for turning on the air purifier
alias: "Turn on the air purifier when PM2.5 is high"
triggers:
- trigger: numeric_state
entity_id: sensor.airly_pm2_5
above: 25
actions:
- action: fan.turn_on
target:
entity_id: fan.air_purifier
Then create the second automation:
-
Trigger: Numeric state crossed threshold
-
Entity: PM2.5 (
sensor.airly_pm2_5) -
Below:
15
-
Entity: PM2.5 (
-
Action: Turn off fan
-
Target: Air purifier (
fan.air_purifier)
-
Target: Air purifier (
YAML example for turning off the air purifier
alias: "Turn off the air purifier when PM2.5 is low"
triggers:
- trigger: numeric_state
entity_id: sensor.airly_pm2_5
below: 15
actions:
- action: fan.turn_off
target:
entity_id: fan.air_purifier
Data updates
Airly API allows 100 data updates per day. For this reason, the more Airly instances configured, the less frequent updates will be. For one configured Airly instance, data will be updated every 15 minutes, for two configured instances, data will be updated every 30 minutes, for three configured instances, data will be updated every 45 minutes, and so on.
Known limitations
Airly allows 100 data updates per day. Data updates become less frequent as you add Airly integration instances, as described in Data updates.
Troubleshooting
Can’t set up the integration: no measuring stations in this area
Symptom: No Airly measuring stations in this area
When you try to set up the integration, Home Assistant shows the message “No Airly measuring stations in this area.”
Description
Airly only provides data for locations covered by its measuring stations. During setup, the integration first looks for data at the exact coordinates you entered. If there is no data for that point, it looks for the nearest station within 5 kilometers. If neither search finds a station, setup stops with this message.
Resolution
- Open the Airly map and check whether there is a measuring station near your location.
- If there is a station nearby, set up the integration again and enter coordinates closer to that station.
Sensors are unavailable
Symptom: Sensors become unavailable
The Airly sensors show as unavailable, or the Airly entry on the Settings > Devices & services page shows Retrying setup. Settings > System > Logs contains a message like “An error occurred while retrieving data from the Airly API for Airly: …”.
Description
The integration marks its sensors as unavailable when it can’t get data from Airly. The text after the colon tells you why:
- “no measuring stations in this area”: The measuring station nearest to your location stopped reporting data. Stations can be offline temporarily, or they can be removed.
-
AirlyError(429, ...): The daily request limit of your API key has been used up. The limit is reset at midnight UTC. - Any other text: Home Assistant can’t reach the Airly service, or the service returned an error.
Resolution
- If the station stopped reporting, open the Airly map and check whether the station is still active. If the station is back, the sensors become available again on their own. If the station is gone, add the integration again with coordinates near another station, then remove the old entry. The location of an existing entry can’t be changed. The new entry creates new sensors, so update any automations and dashboards that use the old ones.
- If the request limit has been used up, wait until midnight UTC. The sensors become available again on their own. If this happens regularly, check whether the same API key is also used by other applications or by another Home Assistant installation. To see how many requests are left, go to Settings > System > Repairs, select the three dots
menu, and select System information. - In all other cases, check that Home Assistant can reach the internet. The integration tries again automatically.
Some sensors are missing
Symptom: Some sensors from the sensors list are not created
Some of the sensors, for example Carbon monoxide or Ozone, don’t exist for your Airly entry.
Description
The integration creates sensors only for the measurements that the nearest station reported when the integration was set up. Not every station measures every value.
Resolution
If the station started reporting additional values later, reload the integration. Go to Settings > Devices & services, select Airly, select the three dots
Home Assistant asks for a new API key
Symptom: Authentication failed for Airly, please update your API key
Home Assistant asks you to reauthenticate the Airly integration, or the log shows the message “Authentication failed for Airly, please update your API key”.
Description
Your API key is no longer accepted by Airly. This happens, for example, when the key was revoked or regenerated on the Airly for developers page.
Resolution
- Generate a new API key on the Airly for developers page.
- If Home Assistant shows a reauthentication prompt, select it and enter the new API key.
- Otherwise, go to Settings > Devices & services, select Airly, select the three dots
menu next to the entry, and select Reconfigure. Enter the new API key.
If the new key is rejected with the message “No Airly measuring stations in this area.”, the station near your location is no longer available. See the resolution for unavailable sensors.
Removing the integration
This integration follows standard integration removal. No extra steps are required.
To remove an integration instance from Home Assistant
- Go to Settings > Devices & services and select the integration card.
- From the list of devices, select the integration instance you want to remove.
- Next to the entry, select the three dots
menu. Then, select Delete.