As an author of Air Quality binding this got me interested!
Recently @splatch sent me some info about Airly - a service that aggregates air quality measurements from various sources.
Just like aqicn.org it allows you to create a developer account, so you can consume the data within your service.
An openHAB instance is just ideal way to utilize this data.
When air quality goes bad outside, you can automatically turn on e.g. an air purifier (like the Xiaomi Air Purifier which already works with openHAB thanks to @marcel_verpaalen ) or send a notification to your phone to close the windows if any is open
A few notes
I’m not sure what’s the real range of Airly. Lots of my colleagues is using it in Poland. Make sure it works in your location before you jump in
The difference between Aqicn and this one - if found that the measurements are more accurate here. Plus, they’re updated more frequently, at least here in Kraków.
Incorporating Airly in Air Quality binding - I’d love to see some contributions!
Set your latitude and longitude properly (e.g. latitude=50.12345&longitude=19.12345)
(optionally) adjust/decrease the maxDistance parameter so it matches your exact location. Please make sure though that the URL returns valid data, before you paste it into config file.
Change the API Key in airly.url parameter to match the key you’ve obtained at Airly API Docs.
Set update interval to one hour (3600000 milliseconds).
After 28.02.2019 the support for API 1.0 will be dropped.
I still use OHv1 I tried to adapt it using new API v2. Please find my configuration.
Due to rate limiting on airly.pl website I fetch json file to the local webserver and then re-use it in configuration.
Group gAirly "Airly"
Number Airly_Aqi "Air Quality [%.1f]" <line> (gAirly) {http="<[http://www.localserver.local/airly.json:100000:JSONPATH($.current.indexes[0].['value'])]"}
Number Airly_Pm25 "Pm\u2082\u2085 [%.2f]" <line> (gAirly) {http="<[http://www.localserver.local/airly.json:100000:JSONPATH($.current.values[1].value)]"}
Number Airly_Pm10 "Pm\u2081\u2080 [%.2f]" <line> (gAirly) {http="<[http://www.localserver.local/airly.json:100000:JSONPATH($.current.values[2].value)]"}
Number Airly_Pressure "Pressure [%.1f hPa]" <line> (gAirly) {http="<[http://www.localserver.local/airly.json:100000:JSONPATH($.current.values[3].value)]"}
Number Airly_Humidity "Humidity [%.2f %%]" <line> (gAirly) {http="<[http://www.localserver.local/airly.json:100000:JSONPATH($.current.values[4].value)]"}
Number Airly_Temperature "Temperature [%.1f °C]" <temperature> (gAirly) {http="<[http://www.localserver.local/airly.json:100000:JSONPATH($.current.values[5].value)]"}
String Airly_Desc "Desc: [%s]" <line> (gAirly) {http="<[http://www.localserver.local/airly.json:100000:JSONPATH($.current.indexes[0].['description'])]"}
String Airly_Advice "Adv: [%s]" <line> (gAirly) {http="<[http://www.localserver.local/airly.json:100000:JSONPATH($.current.indexes[0].['advice'])]"}
I had a problem get a number value for Air Quality index. I received value in square brackets. I found that it has to be extracted from json using this syntax: [‘value’]. The same for description and advice which return a string.
(OpenHAB1.x note): If you want to use API URL direclty in Items, you have to sent right headers. Example of binding will be:
Number Airly_Pm25 "Pm\u2082\u2085 [%.2f]" <line> (gAirly) {http="<[http="<[https://airapi.airly.eu/v2/measurements/point?lat=50.262006&lng=19.980984{Accept:application/json&apikey=yolMiLfyrQXXXXXXXXXXaK8ad782k3}:100000:JSONPATH($.current.values[1].value)]"}
Sitemap:
Frame label="Airly" {
Text item=Airly_Aqi valuecolor=[Airly_Aqi=="-"="lightgray",Airly_Aqi>=300="#7e0023",>=201="#660099",>=151="#cc0033",>=101="#ff9933",>=51="#ffde33",>=0="#009966"]
//Text item=Airly_Aqi
Text item=Airly_Pm25
Text item=Airly_Pm10
Text item=Airly_Pressure
Text item=Airly_Temperature
Text item=Airly_Humidity
Text item=Airly_Desc
Text item=Airly_Advice
}
as more resistant to changes in the index of measurements in the response from the API.
I query 3 installations (URLs) and for each update interval for: