Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Weather
#11
(2019 May 07, 03:45 PM)dan Wrote:
(2019 May 07, 03:09 PM)dan Wrote:
(2019 May 07, 04:31 AM)esawyja Wrote:
(2019 May 06, 02:55 PM)dan Wrote:
(2019 May 06, 05:21 AM)esawyja Wrote: Thanks Dan, when I fill in all the details AppID etc from yahoo, I get internal server error when I submit. How would I check to see if it is working? Under options I set the location, does it use that to get the weather? If I run it manually I get

pi@SIP:~/SIP/plugins $ sudo python weather_adj.py
Traceback (most recent call last):
  File "weather_adj.py", line 17, in <module>
    from urls import urls  # Get access to SIP's URLs
ImportError: No module named urls
pi@SIP:~/SIP/plugins $

It looks like you are running SIP from the plugins directory. That is why it can't find the urls module (urls.py).
Try running SIP from the SIP directory.
Hi Dan,

Still the same
pi@PI:~/SIP $ sudo python plugins/weather_adj.py
Traceback (most recent call last):
  File "plugins/weather_adj.py", line 17, in <module>
    from urls import urls  # Get access to SIP's URLs
ImportError: No module named urls
pi@PI:~/SIP $ ls -ltr
total 240
-rw-r--r--  1 pi   pi    1339 May  4 12:18 ReverseProxied.py
-rw-r--r--  1 pi   pi   16259 May  4 12:18 README.md
-rwxr-xr-x  1 pi   pi    6974 May  4 12:18 gpio_pins.py
-rw-r--r--  1 pi   pi    1243 May  4 12:18 i18n.py
-rw-r--r--  1 pi   pi   17517 May  4 12:18 helpers.py
-rw-r--r--  1 pi   pi    3631 May  4 12:18 gv_reference.txt
-rw-r--r--  1 pi   pi    6828 May  4 12:18 gv.py
-rw-r--r--  1 pi   pi    4415 May  4 12:18 pigpiod.sh
lrwxrwxrwx  1 pi   pi       6 May  4 12:18 ospi.py -> sip.py
drwxr-xr-x 14 pi   pi    4096 May  4 12:18 i18n
-rwxr-xr-x  1 pi   pi   11492 May  4 12:18 sip.py
-rw-r--r--  1 pi   pi     652 May  4 12:18 rtcdev.sh
-rwxr-xr-x  1 pi   pi    4637 May  4 12:18 sip.sh
-rw-r--r--  1 pi   pi     317 May  4 12:18 sip.service
drwxr-xr-x  8 pi   pi    4096 May  4 12:18 static
-rw-r--r--  1 pi   pi    1135 May  4 12:18 urls.py
-rw-r--r--  1 pi   pi   21943 May  4 12:18 webpages.py
-rw-r--r--  1 root root  1476 May  4 12:18 i18n.pyc
drwxr-xr-x  4 pi   pi    4096 May  4 12:18 web
-rw-r--r--  1 root root  5973 May  4 12:18 gv.pyc
-rw-r--r--  1 root root 18260 May  4 12:18 helpers.pyc
drwxr-xr-x  2 pi   pi    4096 May  4 12:18 blinker
-rw-r--r--  1 root root  5350 May  4 12:18 gpio_pins.pyc
-rw-r--r--  1 root root  1260 May  4 12:18 urls.pyc
-rw-r--r--  1 root root  1804 May  4 12:18 ReverseProxied.pyc
-rw-r--r--  1 root root  6570 May  4 12:18 sip.pyc
-rw-r--r--  1 root root 23269 May  4 12:18 webpages.pyc
drwxr-xr-x  2 pi   pi    4096 May  6 07:17 templates
drwxr-xr-x  3 pi   pi    4096 May  6 07:18 plugins
drwxr-xr-x  2 pi   pi    4096 May  6 07:19 data
drwxr-xr-x  2 root root  4096 May  7 05:29 sessions
pi@PI:~/SIP $ cat urls.py
# !/usr/bin/env python
# -*- coding: utf-8 -*-

 #### urls is used by web.py. When a GET request is received, the corresponding class is executed.
urls = [
    '/',  'webpages.home',
    '/cv', 'webpages.change_values',
    '/vo', 'webpages.view_options',
    '/co', 'webpages.change_options',
    '/vs', 'webpages.view_stations',
    '/cs', 'webpages.change_stations',
    '/sn', 'webpages.get_set_station',
    '/vr', 'webpages.view_runonce',
    '/cr', 'webpages.change_runonce',
    '/vp', 'webpages.view_programs',
    '/mp', 'webpages.modify_program',
    '/cp', 'webpages.change_program',
    '/dp', 'webpages.delete_program',
    '/ep', 'webpages.enable_program',
    '/vl', 'webpages.view_log',
    '/cl', 'webpages.clear_log',
    '/lo', 'webpages.log_options',
    '/rp', 'webpages.run_now',
    '/ttu', 'webpages.toggle_temp',
    '/rev', 'webpages.show_revision',
    '/wl', 'webpages.water_log',
    '/api/status', 'webpages.api_status',
    '/api/log', 'webpages.api_log',
    '/login', 'webpages.login',
    '/logout', 'webpages.logout',
    '/restart', 'webpages.sw_restart',
    '/rss', 'webpages.rain_sensor_state'
]pi@PI:~/SIP $

I just cannot get this to work.....
Regards

The plugin will not run as a stand alone program. You would need to run SIP and then try to access the plugin from within SIP to get the error from the plugin.

I will try to do some testing here and let you know the result.

After looking at the privacy statement on the Oath/yahoo sign up page I prefer not to sign up for an account. They apparently give themselves the right to read your email, track you location and more.

I am thinking of rolling back the update for the weather_adj plugin.

I did not even read the Oath, just accepted, It would be a shame not to have a weather plugin, what about Open Weather, like what OpenSprinkler uses? Is there no plugin for that please
Reply
#12
OK. I will leave the plugin as is for now.

I will dig into the code and see if I can fix the server error without having a consumer key or consumer secret.

There has been a suggestion for another source of weather data:
http://www.7timer.info/doc.php?lang=en

I will take a look at the possibility of using that.
Reply
#13
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.
Reply
#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
#15
When there is a rain delay it will show on the home page.

There has been a new development.
A user has updated the plugin to use Open weather maps:
https://github.com/Dan-in-CA/SIP/issues/219


It has not been merged on the SIP plugins repository yet but should happen soon.
Reply
#16
(2019 May 09, 02:48 PM)dan Wrote: When there is a rain delay it will show on the home page.

There has been a new development.
A user has updated the plugin to use Open weather maps:
https://github.com/Dan-in-CA/SIP/issues/219


It has not been merged on the SIP plugins repository yet but should happen soon.

Thanks Dan, I'll wait for the merge
Reply
#17
Any news on the merge please?
Reply
#18
Not yet.

The plugin is still being worked on so it may be a while.
Reply
#19
Thanks Dan
Reply
#20
The weather plugins have been updated to use OpenWeatherMap.
See info on GitHub:
https://github.com/Dan-in-CA/sip_plugins/pull/33
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)