Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
openHAB Air Quality Index measurement
Number AirQualityIndex "AQI"
String AirQuality "Air Quality [SCALE(airquality.scale):%s]"
Switch AirQualityRerun "Measure AQI"
rule "Test AirQuality"
when
Time cron "0 0 * * * ?" or
Item AirQualityRerun received command ON
then {
var String coordinates = "37.14360;-115.482399"
var String token = "YOURTOKEN"
var response = sendHttpGetRequest("http://api.waqi.info/feed/geo:" + coordinates + "/?token=" + token, 3000)
var aqi = transform("JSONPATH","$.data.aqi", response.toString)
AirQualityIndex.postUpdate(aqi)
AirQuality.postUpdate(aqi)
AirQualityRerun.postUpdate(OFF)
}
end
-=No data
[0..50]=Good
[51..100]=Moderate
[101..150]=Unhealthy for Sensitive Groups
[151..200]=Unhealthy
[201..300]=Very Unhealthy
[300..]=Hazardous
-=Brak danych
[0..50]=Dobra
[51..100]=Średnia
[101..150]=Niezdrowa dla osób wrażliwych
[151..200]=Niezdrowa
[201..300]=Bardzo niezdrowa
[300..]=Zagrożenie dla życia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment