Get Weather for Daily Journal

If anyone is looking to add the daily weather information to their Daily Journal script (see the provided template) here is a handler that uses open source information. The point of providing this is that it does not depend on Yahoo, or Google, o news feeds or other information and, in my experience so far, is pretty reliable.

You can add this into your scripts.

(That’s your homework – you can figure it out if you try a little.)


Location Helper from the Mac App Store (no cost).
JSON Helper for AppleScript also from the Mac App Store (no cost).
API Key From OpenWeather – free for 1,000,000 API calls/month – be careful – don’t go wild with this :smile:

The handler

This uses getWX() to get the data from OpenWeather and format it into a list. You can adjust the API call and JSON parsing to whatever other OpenWeather data you wish.

Click to see the AppleScript
on getWX()
	-- REQUIREMENTS - tested as of 20201117
	-- 1a -- Install of JSON Helper from Mac App Store
	-- 1b -- Install Location Helper from Mac App Store
	-- 1c -- Grant Location Helper access to location in System Preferences > Security & Privacy
	-- 2 -- An API key from Open Weather
	-- no charge for personal use as of 20201117
	-- 3 -- Your location's latitude and longitude 
	tell application "JSON Helper"
			(* Get my latitude and longitude*)
			tell application "Location Helper"
				set listCoords to get location coordinates
				set _lat to item 1 of listCoords as text
				set _lon to item 2 of listCoords as text
			end tell
			set myWXdisplay to ""
			(* Get current weather from OpenWeather *)
			set getWXsource to fetch JSON from ("" & _lat & "&lon=" & _lon & "&exclude=minutely,hourly&units=imperial&appid=2eb42d36ca731adc915cc0f4e694cc85")
			set getWX to "High: " & temp_max of main of getWXsource & return & return & "Low: " & temp_min of main of getWXsource & return & return & "Current: " & temp of main of getWXsource & return & return & "Humidity: " & humidity of main of getWXsource & return & return & "Conditions: " & description of item 1 of weather of getWXsource
			set myWXdisplay to "## Weather" & return & return & getWX & return & return
		end try
		return myWXdisplay
	end tell
end getWX

Nice! Thanks for sharing this resource. :slight_smile:

I made this brute force iOS shortcut to do something similar - get weather info to add to a daily journal entry. There might be a better way to do it but I’m learning shortcuts.

Weather Shortcut


Nicely done!
And if it scratches your itch, then it’s even better :wink: