From mboxrd@z Thu Jan  1 00:00:00 1970
From: Thorsten Jolitz <tjolitz@gmail.com>
Subject: Re: org-weather for openweathermap.org
Date: Sat, 14 Jun 2014 16:02:47 +0200
Message-ID: <87sin7twqg.fsf@gmail.com>
References: <871turvdom.fsf@dylan.nashville>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org>
Received: from eggs.gnu.org ([2001:4830:134:3::10]:32832)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1WvoXy-0007NG-1q
	for emacs-orgmode@gnu.org; Sat, 14 Jun 2014 10:03:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1WvoXt-0006wx-2C
	for emacs-orgmode@gnu.org; Sat, 14 Jun 2014 10:03:06 -0400
Received: from plane.gmane.org ([80.91.229.3]:58665)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1WvoXs-0006wt-Nw
	for emacs-orgmode@gnu.org; Sat, 14 Jun 2014 10:03:00 -0400
Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1WvoXq-0001AU-Nl
	for emacs-orgmode@gnu.org; Sat, 14 Jun 2014 16:02:58 +0200
Received: from g231110097.adsl.alicedsl.de ([92.231.110.97])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <emacs-orgmode@gnu.org>; Sat, 14 Jun 2014 16:02:58 +0200
Received: from tjolitz by g231110097.adsl.alicedsl.de with local (Gmexim 0.1
	(Debian)) id 1AlnuQ-0007hv-00
	for <emacs-orgmode@gnu.org>; Sat, 14 Jun 2014 16:02:58 +0200
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
To: emacs-orgmode@gnu.org

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