OpenSprinkler Forums OpenSprinkler Mobile and Web App Mobile Web App with Screenshots (Updated)

  • This topic is empty.
Viewing 25 posts - 26 through 50 (of 559 total)
  • Author
    Posts
  • #23863

    Samer
    Keymaster

    Okay, 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!

    #23864

    slobrewer
    Member

    Wow, 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.

    #23865

    momanz
    Member

    Nice 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,
    -m

    #23866

    Samer
    Keymaster

    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.

    #23867

    JBinkley
    Member

    😀 😀

    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

    #23868

    Samer
    Keymaster

    Thank 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!

    #23869

    Samer
    Keymaster

    @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.

    #23870

    Samer
    Keymaster

    Okay 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
    #23871

    slobrewer
    Member

    @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.

    #23872

    Samer
    Keymaster

    Did the change in the python code I suggested above allow manual mode to work in my web app?

    #23873

    slobrewer
    Member

    Sorry, had to step away to take care of something. I’m going to try it right now.

    #23874

    slobrewer
    Member

    That’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.

    #23875

    Samer
    Keymaster

    Okay 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!

    #23876

    slobrewer
    Member

    Wait, 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.

    #23877

    Samer
    Keymaster

    My 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!

    #23878

    slobrewer
    Member

    Perfect. I’ll poke around a bit later tonight.

    #23879

    Samer
    Keymaster

    I 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!

    #23880

    Samer
    Keymaster

    The 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.

    #23881

    Still can’t get past installation. I’m getting the “Settings were not saved. Check file path and permissions.”

    #23882

    Samer
    Keymaster

    There 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!

    #23883

    My 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.

    #23884

    Samer
    Keymaster

    Okay 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!

    #23885

    momanz
    Member

    @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

    #23886

    Samer
    Keymaster

    That’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!

    #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.

Viewing 25 posts - 26 through 50 (of 559 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums OpenSprinkler Mobile and Web App Mobile Web App with Screenshots (Updated)