emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: org-weather for openweathermap.org
Date: Sat, 14 Jun 2014 16:02:47 +0200	[thread overview]
Message-ID: <87sin7twqg.fsf@gmail.com> (raw)
In-Reply-To: 871turvdom.fsf@dylan.nashville

Chris Raschl <cr@kautsig.org> writes:

> Hi everybody,
>
> recently I wanted to add a weather forecast to my org-agenda. I found
> org-google-weather, but this package is obsolete since 2012, because the
> API is not available any more. So I wrote my own version which is backed
> by the openweathermap.org API.
>
> I implemented the minimal usecase which works for me, if somebody else
> dares to use it, its available here:
>
> https://github.com/kautsig/org-weather

Nice, thank you, never made org-google-weather, but this works
out-of-the-box:

  ,-------------------------------------------------
  | City:     Weather: light rain, 10.43°C - 17.58°C
  `-------------------------------------------------

A few suggestions wrt

,--------------------------------------------------------------------------
| (defun org-weather-add-to-cache (item)
|   "Adds the one result 'list' item to the data cache"
|   (let* ((timestr (cdr (assoc 'dt item)))
|          (cache-key (format-time-string "%F" (seconds-to-time timestr)))
|          (weather (cdr (assoc 'weather item)))
|          (temperature (cdr (assoc 'temp item)))
|          (temp-min (number-to-string (org-weather-temp-min temperature)))
|          (temp-max (number-to-string (org-weather-temp-max temperature)))
|          (data (concat (org-weather-description weather) ", "
|          temp-min org-weather-unit " - " temp-max org-weather-unit)))
|     (puthash cache-key data  org-weather-data)))
`--------------------------------------------------------------------------

- why not use (round ...) for the temperature data, 10-17°C would be
  more than accurate enough?

- why not include city/country info in the weather string? I added 

  * Weather
    :PROPERTIES:
    :CATEGORY: City
    :END:
  %%(org-weather)

  to get the above, but it would be much better to take the return
  values for city/country and include them in the weather string, to
  make sure one did not mess up the configuration and gets the weather
  from another place than expected.

- maybe make the whole thing a bit customizable by adding a few
  defcustoms, so the user can decide which info he wants to print in the
  agenda

  the return string looks like this, there are many options:

,-------------------------------------------------------------------------
| Contacting host: api.openweathermap.org:80 ((list . [((rain . 0.5)
| (clouds . 92) (deg . 353) (speed . 4.41) (weather . [((icon . 10d)
| (description . light rain) (main . Rain) (id . 500))]) (humidity . 88)
| (pressure . 1023.69) (temp (morn . 18.53) (eve . 17.32) (night . 11.63)
| (max . 19.01) (min . 11.63) (day . 18.53)) (dt . 1402743600)) ((clouds
| . 68) (deg . 334) (speed . 2.97) (weather . [((icon . 04d) (description
| . broken clouds) (main . Clouds) (id . 803))]) (humidity . 75) (pressure
| . 1027.85) (temp (morn . 15.35) (eve . 18.45) (night . 9.04) (max
| . 19.62) (min . 9.04) (day . 19.62)) (dt . 1402830000)) ((rain . 0.5)
| (clouds . 80) (deg . 264) (speed . 3.46) (weather . [((icon . 10d)
| (description . light rain) (main . Rain) (id . 500))]) (humidity . 75)
| (pressure . 1024.55) (temp (morn . 14.54) (eve . 16.83) (night . 14.58)
| (max . 19.07) (min . 14.54) (day . 19.07)) (dt . 1402916400)) ((clouds
| . 0) (deg . 248) (speed . 2.25) (weather . [((icon . 01d) (description
| . sky is clear) (main . Clear) (id . 800))]) (humidity . 88) (pressure
| . 1024.46) (temp (morn . 14.99) (eve . 17.74) (night . 9.9) (max
| . 20.82) (min . 9.9) (day . 20.82)) (dt . 1403002800)) ((clouds . 76)
| (deg . 261) (speed . 6.56) (weather . [((icon . 04d) (description
| . broken clouds) (main . Clouds) (id . 803))]) (humidity . 78) (pressure
| . 1024.87) (temp (morn . 14.25) (eve . 19.07) (night . 14.95) (max
| . 19.37) (min . 14.25) (day . 18.81)) (dt . 1403089200)) ((rain . 4.45)
| (clouds . 35) (deg . 288) (speed . 6.29) (weather . [((icon . 10d)
| (description . moderate rain) (main . Rain) (id . 501))]) (humidity . 0)
| (pressure . 1016.64) (temp (morn . 15.26) (eve . 18.07) (night . 13.78)
| (max . 19.68) (min . 13.78) (day . 19.68)) (dt . 1403175600)) ((rain
| . 1.34) (clouds . 36) (deg . 289) (speed . 5.59) (weather . [((icon
| . 10d) (description . light rain) (main . Rain) (id . 500))]) (humidity
| . 0) (pressure . 1016.73) (temp (morn . 15.05) (eve . 18.08) (night
| . 15.57) (max . 18.86) (min . 15.05) (day . 18.86)) (dt . 1403262000))])
| (cnt . 7) (city (sys (population . 0)) (population . 0) [...]
`-------------------------------------------------------------------------



-- 
cheers,
Thorsten

  parent reply	other threads:[~2014-06-14 14:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-14 13:11 org-weather for openweathermap.org Chris Raschl
2014-06-14 13:41 ` Fletcher Charest
2014-06-14 14:02 ` Thorsten Jolitz [this message]
2014-06-15  9:47   ` Chris Raschl
2014-06-15 11:54     ` Thorsten Jolitz
2014-06-16 10:07       ` Ian Barton
2014-06-16 10:45         ` Thorsten Jolitz
2014-06-16 15:04           ` Ian Barton
2014-06-17 10:34             ` Thorsten Jolitz
2014-06-16  9:59     ` Thorsten Jolitz
2014-06-16  8:04 ` Rüdiger Sonderfeld
2014-06-16 13:10   ` Alan Schmitt
2014-06-27 12:50   ` Andreas Leha
2014-06-16 14:40 ` Doyley, Marvin
2014-06-16 15:47   ` Nick Dokos
2014-06-16 16:11     ` Doyley, Marvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sin7twqg.fsf@gmail.com \
    --to=tjolitz@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).