You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Logger.w("Air Quality", "AQICN API error: "+ (response.data??"unknown"))
137
+
root.loading=false
138
+
return
139
+
}
140
+
var data =response.data
141
+
root.usAqi=data.aqi??0
142
+
root.europeanAqi=0
143
+
root.pm25=data.iaqi?.pm25?.v??0
144
+
root.pm10=data.iaqi?.pm10?.v??0
145
+
root.ozone=data.iaqi?.o3?.v??0
146
+
root.no2=data.iaqi?.no2?.v??0
147
+
root.co=data.iaqi?.co?.v??0
148
+
root.so2=data.iaqi?.so2?.v??0
149
+
root.stationName=data.city?.name??""
150
+
root.hasData=true
151
+
152
+
var now =newDate()
153
+
root.lastUpdate=Qt.formatTime(now, "HH:mm")
154
+
155
+
Logger.i("Air Quality", "AQICN data updated — AQI: "+root.usAqi+" Station: "+root.stationName)
156
+
} catch (e) {
157
+
Logger.e("Air Quality", "Failed to parse AQICN response: "+e.message)
158
+
}
159
+
root.loading=false
160
+
}
161
+
}
162
+
}
163
+
113
164
// Get current AQI value based on selected scale
114
165
functiongetAqi() {
115
166
return aqiScale ==="eu"? europeanAqi : usAqi
@@ -157,6 +208,9 @@ Item {
157
208
158
209
// Get location name for display
159
210
functiongetLocationName() {
211
+
if (dataSource ==="aqicn"&& stationName) {
212
+
return stationName
213
+
}
160
214
if (useNoctaliaLocation) {
161
215
var name =Settings.data.location?.name??""
162
216
if (name) {
@@ -220,9 +274,24 @@ Item {
220
274
}
221
275
222
276
root.loading=true
223
-
var url ="https://air-quality-api.open-meteo.com/v1/air-quality?latitude="+ lat +"&longitude="+ lon +"¤t=us_aqi,european_aqi,pm2_5,pm10,ozone,nitrogen_dioxide,carbon_monoxide,sulphur_dioxide&timezone=auto"
var url ="https://air-quality-api.open-meteo.com/v1/air-quality?latitude="+ lat +"&longitude="+ lon +"¤t=us_aqi,european_aqi,pm2_5,pm10,ozone,nitrogen_dioxide,carbon_monoxide,sulphur_dioxide&timezone=auto"
Copy file name to clipboardExpand all lines: air-quality/README.md
+15-7Lines changed: 15 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,18 @@
1
1
# Air Quality
2
2
3
-
Displays real-time air quality data from the Open-Meteo API with EPA color coding.
3
+
Displays real-time air quality data with EPA color coding.
4
4
Shows AQI index (US EPA or European scale) and pollutant breakdown for PM2.5, PM10, O3, NO2, CO, and SO2.
5
5
6
+
## Data Sources
7
+
8
+
| Source | Type | API Key | AQI Scales |
9
+
|--------|------|---------|------------|
10
+
|**Open-Meteo** (default) | Forecasting (CAMS atmospheric models) | Not required | US EPA, European |
11
+
|**AQICN**| Real monitoring station data | Free token required | US EPA only |
12
+
13
+
-**Open-Meteo** uses Copernicus CAMS atmospheric models at 11-40km resolution. No API key needed, but values are forecasted estimates.
14
+
-**AQICN** provides real-time data from the nearest EPA monitoring station. Requires a free API token from [aqicn.org/data-platform/token](https://aqicn.org/data-platform/token). Shows the station name in the location pill.
15
+
6
16
## Features
7
17
8
18
**Bar Widget**
@@ -14,7 +24,7 @@ Shows AQI index (US EPA or European scale) and pollutant breakdown for PM2.5, PM
14
24
15
25
**Panel**
16
26
- Large AQI number with level indicator
17
-
- Location pill with last update time
27
+
- Location pill with last update time (shows station name when using AQICN)
18
28
- Pollutant rows with colored indicators
19
29
- Refresh and settings buttons
20
30
@@ -25,15 +35,13 @@ Shows AQI index (US EPA or European scale) and pollutant breakdown for PM2.5, PM
25
35
- Middle click to refresh
26
36
27
37
**Settings**
28
-
- AQI scale: US AQI (EPA) or European AQI
38
+
- Data source: Open-Meteo (forecasting) or AQICN (real station data)
39
+
- AQICN API token field (visible when AQICN selected)
40
+
- AQI scale: US AQI (EPA) or European AQI (disabled when using AQICN)
29
41
- Location: use Noctalia location or custom coordinates
0 commit comments