Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Weather
#14
(2019 May 08, 05:08 PM)dan Wrote: Looks like 7timer is pretty easy to use.

I made a short Python program to get the predicted amount of precipitation for today.


Code:
from __future__ import print_function
import json
import urllib2

lat = 23.09 #  Example. Replace with your latitude
lon = 113.17 #  Example. Replace with your longitude
day_precip = 0

url = "http://www.7timer.info/bin/api.pl?lon={}&lat={}&product=civil&output=json".format(lon, lat)
request = urllib2.Request(url)
data = urllib2.urlopen(request).read()
py_data = json.loads(data)
day_data = py_data["dataseries"][:8]

for i in day_data:
    day_precip += i["prec_amount"]
    
print("predicted precip (mm): ", day_precip)

Note that you do not need a key to access the data just your longitude and latitude which you can find from google maps and other sources.

I will try to make a new weather plugin using 7timer. It may be a few days.

Thanks Dan, that would be brilliant, let me know if I can test or something to help. Would it be possible to put some kind of indication on the GUI that indicates the system has been delay because of rain prediction?
Reply


Messages In This Thread
Weather - by esawyja - 2019 May 05, 07:55 AM
RE: Weather - by dan - 2019 May 05, 03:46 PM
RE: Weather - by esawyja - 2019 May 06, 05:21 AM
RE: Weather - by dan - 2019 May 06, 02:55 PM
RE: Weather - by esawyja - 2019 May 07, 04:31 AM
RE: Weather - by dan - 2019 May 07, 03:09 PM
RE: Weather - by dan - 2019 May 07, 03:45 PM
RE: Weather - by esawyja - 2019 May 08, 03:13 AM
RE: Weather - by marcusp - 2019 May 06, 12:35 PM
RE: Weather - by dan - 2019 May 06, 03:05 PM
RE: Weather - by marcusp - 2019 May 06, 08:43 PM
RE: Weather - by dan - 2019 May 08, 03:04 PM
RE: Weather - by dan - 2019 May 08, 05:08 PM
RE: Weather - by esawyja - 2019 May 09, 04:24 AM
RE: Weather - by dan - 2019 May 09, 02:48 PM
RE: Weather - by esawyja - 2019 May 10, 05:19 AM
RE: Weather - by esawyja - 2019 May 14, 10:28 AM
RE: Weather - by dan - 2019 May 14, 02:35 PM
RE: Weather - by esawyja - 2019 May 15, 04:25 AM
RE: Weather - by dan - 2019 May 22, 06:12 PM
RE: Weather - by marcusp - 2019 May 25, 09:36 AM
RE: Weather - by dan - 2019 May 25, 02:54 PM

Forum Jump:


Users browsing this thread: 5 Guest(s)