Air Quality Index in Melbourne is 28 the dominant pollutant is pm25

This commit is contained in:
nik gaffney 2020-02-15 18:39:37 +11:00
parent 31bfbefa91
commit dff57a346b
2 changed files with 23 additions and 2 deletions

View file

@ -20,10 +20,16 @@ To access the WAQI project API its necessary to register at http://aqicn.org/
aqi-use-cache t)
#+END_SRC
The simplest way to view AQI info is with =M-x aqi-report= which displays air quality info for your algorithmically derived location (equivalent to the location ="here"=) or the name of a place. A place can be the name of a city (in which case the nearest monitoring station is used) or the name of specific monitoring station.
The simplest way to view AQI info is with =M-x aqi-report= which displays air quality info for your algorithmically derived location (equivalent to the location "here") or the name of a place. A place can be the name of a city (in which case the nearest monitoring station is used) or the id of specific monitoring station.
By name…
#+BEGIN_SRC emacs-lisp
(aqi-report "Taipei")
(aqi-report "Ulaanbaatar")
#+END_SRC
By id…
#+BEGIN_SRC emacs-lisp
(aqi-report "@7397")
#+END_SRC
A detailed report is displayed by default and a single line summary can be provided by using the keyword ='brief=

15
aqi.el
View file

@ -158,6 +158,21 @@
(aqi--city-cache-get city)
(aqi-request city)))
(defun aqi-search (name)
"Search for the nearest stations (if any) matching a given NAME."
(request
(format "https://api.waqi.info/search/?keyword=%s&" name)
:sync t
:params `(("token" . ,aqi-api-key))
:parser 'json-read
:success (cl-function
(lambda (&key data &allow-other-keys)
(pcase (assoc-default 'status data)
("ok" (message "Search: %s" (assoc-default 'data data)))
("error" (message "Search error: %s" (assoc-default 'data data))))))
:error (cl-function
(lambda (&rest args &key error-thrown &allow-other-keys)
(message "WAQI error: %s" error-thrown)))))
;; printing, formatting and presenting.