OpenSprinkler Forums OpenSprinkler Mobile and Web App Mobile Web App with Screenshots (Updated) Re: Re: Mobile Web App for OpenSprinkler (w/Screenshots)

#23887

Samer
Keymaster

*** UPDATE ***

This has been patched into the offical version of the OSPi code. This patch is no longer needed. Please download the latest version of OSPi from: https://github.com/rayshobby/opensprinkler/tree/master/OpenSprinkler%20Pi/software/demos/interval_program

*** UPDATE ***

Great news for Raspberry Pi users! I have found all the problems in the python script and made the modifications needed to allow my web app to work properly (and also bring the HTTP GET implementation closer to that of the OpenSprinkler).

Below are the changes required. Hopefully Dan sees this (or Ray can tell him) and updates his code if he approves of these changes. All of these changes occur in ospi.py.

I have created a patch file so you can quickly make the changes. The file is available at http://albahra.com/journal/wp-content/uploads/2013/06/rpi.webapp.patch_.txt

To apply the patch simply place it in the same directory as the OSPi files and run the following command:

patch < rpi.webapp.patch_.txt

If you do not want to or cannot use the patch then make the following changes manually:

Find:

    '/sn=(d+?Z)', 'get_station', # regular expression, accepts any station number

Replace with:

    '/sn(d+?Z)', 'get_station', # regular expression, accepts any station number

Find:

        if qdict !='' and qdict == qdict: sd = base64.b64encode(qdict)

Replace with:

        try:
if qdict !='' and qdict == qdict: sd = base64.b64encode(qdict)
except KeyError:
pass

Find:

        if qdict == '':
qdict = '1' #default
elif qdict == '0':
srvals = [0]*(sd) # turn off all stations
set_output()
if qdict == '0': self.clear_mm()
if qdict != '0':
sd = ((time.time()-(time.timezone-(time.daylight*3600)))
+(int(qdict)*3600))
else: sd = 0
if qdict == '1':

Replace with:

        if qdict.has_key('en') and qdict == '':
qdict = '1' #default
elif qdict.has_key('en') and qdict == '0':
srvals = [0]*(sd) # turn off all stations
set_output()
if qdict.has_key('mm') and qdict == '0': self.clear_mm()
if qdict.has_key('rd') and qdict != '0':
sd = ((time.time()-(time.timezone-(time.daylight*3600)))
+(int(qdict)*3600))
elif qdict.has_key('rd') and qdict == '0': sd = 0
if qdict.has_key('rbt') and qdict == '1':

To summarize the changes listed above change how the station status is retrieved from using sn=1 to sn1, for example. The other changes check to see if a variable was supplied and if not continue without error instead of halting.

The last thing remaining is the sequential option which is missing from the interval program for the Raspberry Pi. If you attempt to set this option it will fail. For now avoid it until I can speak with Dan and find a fix.