OpenSprinkler › Forums › OpenSprinkler Mobile and Web App › Mobile Web App with Screenshots (Updated)
- This topic is empty.
-
AuthorPosts
-
June 16, 2013 at 2:15 pm #23863
SamerKeymasterOkay, I updated all the regex and now it *SHOULD* properly grab all variables from either the RPi or OS. I have tested the new regex on the OS and I ran the replies from the RPi version through regexpal.com and found them to be compatibile.
There is yet another issue I just discovered. The RPi does not support /sn0 which returns the status of all stations and it also does not seem to have the option for sequential. I am hoping these fixes should be on the interval program side and not mine. Let me know what you guys think after doing some testing and we can go from there.
Thanks!
June 16, 2013 at 4:31 pm #23864
slobrewerMemberWow, thanks for the fast work there. I pulled your latest from Git and now it definitely shows a lot more of the settings like the station names, which is awesome. I am running into problems setting any values, though. For example, when I got to the manual control page and click the button to turn on my first zone it pops an error “Error communicating with OpenSprinkler. Check your password is correct.” Do you have any suggestions on troubleshooting that? I tried looking through your UI code but it wasn’t immediately apparent to me to tell what’s going on.
June 16, 2013 at 5:00 pm #23865
momanzBlockedNice work. I installed your code last night and I really like this interface. I do have a couple of questions though as I don’t think I have everything working correctly.
My setup:
Host machine: Belkin Share Max N300 (F7D3301/F7D7301) v1 router
Firmware: TomatoUSB by Shibby 1.28 (Linux kernel 2.6.22.19)
Webserver: lighttpd/1.4.32 (ssl) (I’m not using SSL)any additional packages not installed by firmware flash are managed by optware.
Issues:
1) In my lighttpd error log file I have the following error.2013-06-16 07:39:35: (mod_fastcgi.c.2676) FastCGI-stderr: PHP Notice: Undefined variable: SprinklerPattern in /opt/share/www/sprinklers/main.php on line 437
2) I have no entries in the “View Log” page. Only the statement “Viewing data for the last 15 days.” appears.
3) This last one is cosmetic and occurs on both: Firefox and IE10 (Win8): The top line of text appears behind the “Title” heading on the main menu page. See screenshot.
Thanks for the hard work. It wouldn’t surprise me if I have a problem with a config file so any help would be appreciated.
Cheers,
-mJune 16, 2013 at 6:30 pm #23866
SamerKeymasterMy best guess regarding the logging is your router does not have crontab installed which is what runs the ‘watcher.php’ script every minute and saves the results to the $log_file and $log_previous files. I think tomato firmware might have an option to turn on crontab. If it does all you need to do is add the watcher.php to it.
To install crontab you should be able to just use:
ipkg-opt install cron
The crontab line for your router should be something like:
* * * * * cd /opt/share/www/sprinklers; /opt/bin/php-fcgi /opt/share/www/sprinklers/watcher.php
In your config.php check that your $log_file and $log_previous files exist and are writable by PHP.
In regard to the tip header, I have updated the CSS to fix the header in IE10 and Firefox but in the long term I do not think I want to spend much time supporting IE or Firefox since both browsers are primarily desktop and the normal interface is sufficient, IMO.
June 16, 2013 at 6:49 pm #23867
JBinkleyMember😀 😀
Terrific! I had just put together my Raspberry PI OpenSprinkler yesterday. This morning I noticed your posts on the forums and that you had just checked in what sounded like a pretty functional build. I think I had your mobile web app running about 10 minutes later on another PI that I use for my weather station.
Putting it on the same PI as the OpenSprinkler took a little more effort, but that was primarily because I was running the interval program on port 80. Switching the interval program to port 8080 and apache to 80 did the trick. (Guess the other way around would work, too.)
A couple minor things that I’ve noticed:
- On the install screen, the iPhone username field defaults to capitalizing the first letter, but that does not seem to happen on the login screen. I had a little trouble logging in, thinking that I had the wrong password until I realized that apparently usernames are case sensitive.
- You might want to somewhere note that “Open Sprinkler IP:” could be filled with either “
“, “ ” or “ : “
Thanks for putting this together. It’s fantastic.
/joe
June 16, 2013 at 7:05 pm #23868
SamerKeymasterThank you for the feedback! I disabled the autocorrect on the username in both fields now and added the tip about the port into the installer file. I actually had that comment on the config.php but after I switched to an installer I forgot to incorporate it back in.
Glad it is working well!
June 16, 2013 at 7:11 pm #23869
SamerKeymaster@slobrewer I unfortunately cannot debug the problem because when I attempt to set station values on my OSPi setup I get an error (most likely because I disabled all GPIO code). The, unable to communicate, error is because the file_get_contents is returning false which subsequently sends a 0 ajax return. That 0 tells the javascript to show the error message your seeing. From my limited understanding of the OSPi interval program I see it should support http://os_ip/sn1=1 so not sure what might be causing the error. The best thing you can do is navigate to the following URL on your browser and tell me the reply the OpenSprinkler Pi gives you.
http://IP_ADDR/sn1=1
That should turn on station one assuming the OSPi is in manual mode which is triggered by:
http://IP_ADDR/cv?pw=PASSWORD&mm=1
Replace IP_ADDR and PASSWORD with your OpenSprinkler configuration. If either are giving an error then that would be the problem we are experiencing.
Edit: Ray just posted that Dan updated the code for the interval program. Please try the new copy and let me know if the issues have been resolved.
June 16, 2013 at 7:31 pm #23870
SamerKeymasterOkay I found the problem. The interval app uses a different syntax to get the status of stations.
The OS uses:
/sn0
The RPi uses:
/sn=0
The fix can be done by editing the ospi.py file and changing:
'/sn=(d+?Z)', 'get_station', # regular expression, accepts any station number
To:
'/sn(d+?Z)', 'get_station', # regular expression, accepts any station number
June 16, 2013 at 7:45 pm #23871
slobrewerMember@salbahra: I think you’ve got it there with the change in the syntax. Hitting http://IP_ADDR/sn1=1 gives a list index out of range error at ospi.py line 616. Using the syntax you suggested works.
June 16, 2013 at 7:54 pm #23872
SamerKeymasterDid the change in the python code I suggested above allow manual mode to work in my web app?
June 16, 2013 at 7:58 pm #23873
slobrewerMemberSorry, had to step away to take care of something. I’m going to try it right now.
June 16, 2013 at 8:04 pm #23874
slobrewerMemberThat’s getting closer. I can now at least hit /sn0 and get the current status. But I still hit index out of range errors further down in the code.
June 16, 2013 at 8:06 pm #23875
SamerKeymasterOkay great! I had to step out for now but I will scan through the code using the line number you gave me and attempt to come up with a fix.
Thanks for the feedback!
June 16, 2013 at 8:12 pm #23876
slobrewerMemberWait, scratch my latest comment. My Pi changed IP addresses so I had to update the config file. It’s in a bit of a goofy state now due to these index out of range errors.
By the way, can you help me understand your code a bit better. When I do a view source I’m not able to easily see what gets run when I click various buttons. If I could see that I’d be able to trouble shoot much more quickly and even propose some changes myself.
To clarify, if I could easily tell that when you clicked a certain button in your UI you’d call http://IP_ADDR/sn1=1 that would be a big help. I must be missing something obvious but I’m just not seeing that in the source.
June 16, 2013 at 8:19 pm #23877
SamerKeymasterMy UI sends the commands to my PHP code which subsequently sends the commands to the OpenSprinkler. So, in the website code you will notice a command like:
$.get("index.php","action=spon&zone=1")
Then, inside main.php you will find a function called spon that looks like:
function spon() {
send_to_os("http://".$os_ip."/sn".$.REQUEST."=1");
}
This is from memory, I am not at my computer at the moment. But hopefully you get the idea. The send_to_os function just calls file_get_contents and checks if any errors occurred.
Hope this helps!
June 16, 2013 at 9:44 pm #23878
slobrewerMemberPerfect. I’ll poke around a bit later tonight.
June 16, 2013 at 10:45 pm #23879
SamerKeymasterI found why you are getting an index out of range error. It is because it expects a t value to be given, like so:
http://IP_ADDR/sn1=1&t=0
The t variable is how long to keep the zone on, and 0 means indefinitely. Basically, there are a few syntax differences that need to be addressed.
I have updated my code to issue a t=0 now which works fine on both versions (the RPi and the OS).
Let me know if this works better now!
June 16, 2013 at 11:07 pm #23880
SamerKeymasterThe status for all stations now works correctly on the RPi (assuming you applied the fix to the python code, posted here: http://rayshobby.net/phpBB3/viewtopic.php?f=2&t=154&start=30#p759).
The problems I am experiencing now are related to switching manual mode,enable mode, and rain delay because the RPi code submits all the variables each time (and requires them even if not changed…). The problems could also be related to the interval program being based on firmware 1.8.2 which is older than the firmware that this web app was written for.
I will try and find a fix in the python code for this since I do not want to send all the options each time (since the HTTP GET documentation for the interval program says they are optional). I might cross-post this issue to the RPi forum and hope Dan can issue a fix.
I have tested everything else and some of the settings work (all the checkboxes and station renaming), most of the status info shows up properly (except last run time), all of the station status shows up, run once programs work, turning off/on stations in manual mode works, stop all stations works, editing and adding programs is working, and preview programs is working!
We are getting very close at this point just not 100% there.
June 17, 2013 at 12:04 am #23881
ubestbsteppinMemberStill can’t get past installation. I’m getting the “Settings were not saved. Check file path and permissions.”
June 17, 2013 at 12:22 am #23882
SamerKeymasterThere are two things you can do to help debug the situation. First, check you web server error log for any relevant information and post it here: typically /var/log/apache2/error.log.
Also, rename the provided config-example.php to config.php and fill it out manually. After try to navigate to the main page and report any errors you may get.
Thanks!
June 17, 2013 at 12:32 am #23883
ubestbsteppinMemberMy host doesn’t give access to the apache logs. I filled out the config file manually and can get to index.php but it asks for a username and password before letting me continue.
June 17, 2013 at 12:50 am #23884
SamerKeymasterOkay perfect. Using the file path defined in config.php by $pass_file add one line using the following format:
username:hashed_password
In order to get the hashed password copy the following code into a file named test.php and navigate to it:
echo base64_encode(sha1('PASSWORD'));
?>
Replace PASSWORD with whatever you want to login with.
As a side note I suspect the directory housing your files is not writable by PHP or your server’s php.ini is preventing file operations.
Hope that helps!
June 17, 2013 at 1:17 am #23885
momanzBlocked@salbahra wrote:
My best guess regarding the logging is your router does not have crontab installed which is what runs the ‘watcher.php’ script every minute and saves the results to the $log_file and $log_previous files. I think tomato firmware might have an option to turn on crontab. If it does all you need to do is add the watcher.php to it.
To install crontab you should be able to just use:
ipkg-opt install cron
The crontab line for your router should be something like:
* * * * * cd /opt/share/www/sprinklers; /opt/bin/php-fcgi /opt/share/www/sprinklers/watcher.php
In your config.php check that your $log_file and $log_previous files exist and are writable by PHP.
In regard to the tip header, I have updated the CSS to fix the header in IE10 and Firefox but in the long term I do not think I want to spend much time supporting IE or Firefox since both browsers are primarily desktop and the normal interface is sufficient, IMO.
That was it. The command to to run watcher.php never made it into crontab. I manually added the line and now logging works.
Good point on IE and Firefox… the title of this thread is “Mobile Web App…” after all. 😳
Thanks for the quick reply and thanks for this webapp.
-m
June 17, 2013 at 1:29 am #23886
SamerKeymasterThat’s fantastic to hear! Glad it worked out!
Let me know if you have any suggestions as you use the app or if you find any bugs.
The one bug I have experienced so far is the time selection on new programs (and sometimes editing current programs). What happens is the content view scrolls up and the underlying gray background is exposed over half the screen. It is purely a cosmetic bug but should be fixed soon!
June 17, 2013 at 4:02 am #23887
SamerKeymaster*** 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:
passFind:
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.
-
AuthorPosts
- You must be logged in to reply to this topic.
OpenSprinkler › Forums › OpenSprinkler Mobile and Web App › Mobile Web App with Screenshots (Updated)