Some months ago I wrote a simple Python script which outputs some weather data gathered from the Dutch Buienradar’s JSON feed. It contains reliable data coming from a weather station almost in my backyard.
The script:
#!/usr/bin/python3
#
# Uronode Weather info script using Dutch Buienradar JSON feed
#
# v1.0 16-02-2020 by Dave van der Locht <dave.is@home.nl>
#
import urllib.request, json, sys
# Regio needs to correspond with Buienradar's JSON feed entry.
# Just open the URL https://data.buienradar.nl/2.0/feed/json in a webbrowser and search
# for a region (regio) near your own location.
regio = 'Uden'
# Just for some info on the first line of output
country = 'The Netherlands'
qthloc = 'JO21TP'
# ---- DO NOT EDIT BELOW THIS LINE ---- #
with urllib.request.urlopen("https://data.buienradar.nl/2.0/feed/json") as url:
data = json.loads(url.read().decode())
for i in data['actual']['stationmeasurements']:
if i['regio'] == regio:
windspeed = i['windspeed'] * 3.6
windgusts = i['windgusts'] * 3.6
windspeed = str("%.2f" % round(windspeed, 2))
windgusts = str("%.2f" % round(windgusts, 2))
print('This is a current weather report in ' + regio + ', ' + country + ' (' + qthloc + ')')
print('Temperature is: ' + str(i['temperature']) + ' degrees C')
print('Approximate windchill is: ' + str(i['feeltemperature']) + ' degrees C')
print('Wind speed is: ' + windspeed + ' km/h (' + str(i['windspeedBft']) + ' bft)')
print('Wind gusts are: ' + windgusts + ' km/h')
print('Wind direction is: ' + str(i['winddirection']) + ' ' + str(i['winddirectiondegrees']) + ' degrees')
print('Relative humidity is: ' + str(i['humidity']) + ' %')
print('Solar radation is: ' + str(i['sunpower']) + ' W/m2')
print('Barometric pressure is: ' + str(i['airpressure']) + ' hPa')
print('Precipitation is: ' + str(i['precipitation']) + ' mm last hour: ' + str(i['rainFallLastHour']) + ' mm') #last 24 hours: ' + str(i['rainFallLast24Hour']) + ' mm')
print('Visibility is: ' + str(i['visibility'] / 1000) + ' km')
print()
print('Weather report script v1.0 by Dave - NL1VKL')
Just place it somewhere, make it executable (chmod +x) and add it to Uronode’s config as an external command like this:
ExtCmd WEather 1 uronode /usr/local/bin/weather weather
Replace ‘uronode’ with a username able to execute the script.
And voila… A nice weather report for node users who are interested in the current weather at my QTH.