Forum Replies Created

Viewing 25 posts - 1,676 through 1,700 (of 1,705 total)
  • Author
    Posts
  • in reply to: Mobile Web App with Screenshots (Updated) #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!

    in reply to: Mobile Web App with Screenshots (Updated) #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!

    in reply to: Mobile Web App with Screenshots (Updated) #23872

    Samer
    Keymaster

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

    in reply to: Mobile Web App with Screenshots (Updated) #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
    in reply to: Mobile Web App with Screenshots (Updated) #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.

    in reply to: Mobile Web App with Screenshots (Updated) #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!

    in reply to: Mobile Web App with Screenshots (Updated) #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.

    in reply to: Problem with manual mode Interval Program #24501

    Samer
    Keymaster

    I also noticed the interval program on the Raspberry Pi does not seem to return status and only allows changing the station status. Looking at the URL defintions in the python code I see this:


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

    Either case it seems to require an equal sign from what I see.

    in reply to: Mobile Web App with Screenshots (Updated) #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!

    in reply to: Mobile Web App with Screenshots (Updated) #23860

    Samer
    Keymaster

    I updated my previous post but noticed I did so right after your reply. Thank you for the rapid reply and the solid attempt. I ended up solving it a different way by using the view stations page rather then a specific call to the name data. I hope this resolves it and would love your continued feedback!

    Also, I have no specific list but rather a quick scan at the RPi interval program code.

    Edit: I am running the OSPi interval program on my Mac now (removed the GPIO dependency) and noticed a lot of differences in how the data is sent (in the head). I am going to try and change my code to better support the RPi but it will take a little while to develop and test. I will post an update once I have completed the required work.

    Edit 2: Just to give an example of the varations I will post the OS and RPi versions of the home page. My problem is developing a proper regex to parse either case in one go.

    OS:




    RPi:








    I will hopefully find a solution soon that selects everything between a comma that has an equal sign in it. Then I could use the PHP to split by the = and save the array key as the left side and value as right side. The biggest obstacle in this solution are the arrays which also have commas inside so the regex must select each variable independently. The long and short of all this is, I should have a solution soon however if anyone with more experience knows anything that would help I would appreciate it.

    in reply to: Mobile Web App with Screenshots (Updated) #23859

    Samer
    Keymaster

    Fantastic find! You are absolutely correct, I made an assumption that it would work and unfortunately have no means to try it (lack the hardware).

    I appreciate you digging into the code and finding the problem!

    Edit: I looked through the interval program for the RPi and you are absolutely correct, there is no pn.js. I updated the code to use /vs which is available in the RPi along with the normal OS. I am sure other problems exist and would appreciate more feedback. Thank you!

    in reply to: Mobile Web App with Screenshots (Updated) #23857

    Samer
    Keymaster

    Thank you!

    Keep me posted on your results with the new update!

    in reply to: Mobile Web App with Screenshots (Updated) #23855

    Samer
    Keymaster

    I just updated the code to allow non-SSL connection. The code has been pushed to Github and the example configuration has been updated in case the installer is still giving problems.

    The installer will give a checkbox option to force SSL now.

    Hope this helps!

    Edit: I actually tested the updated installer and fixed some bugs. The new option should work properly at this point. Please note without SSL the username/password will be sent plain text to the server.

    in reply to: Mobile Web App with Screenshots (Updated) #23853

    Samer
    Keymaster

    I am currently in the process of developing a program preview option which is almost complete at this point. I am able to update the data live using a date picker and show the proper data. My only problem at this point is how to best visualize this information and would love any feedback. I want to avoid a table view since that is hard to read on an iPhone and I also want to avoid the default OpenSprinkler program preview because it would be crammed on a small screen.

    My thoughts have been displaying an up/down scrolling view similar to calendar view on the iPhone for a specific day. I would just plot the days on the view similar to calendar events for the day. I think this would work fine but would love feedback from others before I develop the UI for it.

    Update: I found this http://almende.github.io/chap-links-library/timeline.html which might be a very nice way to implement the preview. Specifically http://almende.github.io/chap-links-library/js/timeline/examples/example15_mobile.html is what I think would look very well. I will begin incorporating this timeline and push it as soon as it works well.

    in reply to: Mobile Web App with Screenshots (Updated) #23852

    Samer
    Keymaster

    I would like to troubleshoot why the installer is failing though. If you can give me any errors you might encounter inside error.log from /var/logs/apache2/ I would appreciate it.

    After hitting submit, do you see any popup? If so, what is the general gist of the message? “Settings NOT saved”?

    If you are getting a quick popup or no popup I suspect it might be related to my forced SSL setting. When index.php loads it checks if the base url is an https or http. If it is http it forces over to https and if your web server is not configured for SSL that might be the error. I figured it would be safer to send authentication information over SSL and I just realized I do not currently force the installer to use SSL.

    Thank you!

    in reply to: Mobile Web App with Screenshots (Updated) #23851

    Samer
    Keymaster

    Sure, I just posted an example configuration file for this situation.

    The file is available here: https://github.com/salbahra/OpenSprinkler-Controller/blob/master/config-example.php

    in reply to: Mobile Web App with Screenshots (Updated) #23849

    Samer
    Keymaster

    *** UDATE ***

    If your using an external server, you might be better of just using the hosted web app available here: http://rayshobby.net/apps/sprinklers

    *** UPDATE ***

    Absolutely, you would need to forward the HTTP port on the OpenSprinkler so that it is accessible by the external server.

    For example, if your OpenSprinkler is on your home LAN at IP 192.168.1.30 and using port 80. Then you would goto your router’s configuration and forward port 80 for 192.168.1.30. After that you would use your home’s WAN IP for the OpenSprinkler on the external server. The WAN IP can be found by visiting http://wimi.com inside your home.

    A few recommendations for this setup:

    1) Ensure your OpenSprinkler has a static IP using the menu settings on the device OR by setting a static DHCP reservation through your router against the MAC address

    2) You should use a secure password on your OpenSprinkler since it is now accessible outside of your home

    3) You should double check the ‘Ignore Password’ option is unchecked

    4) If it is a shared server, ensure permissions are properly set to prevent unwanted viewing of the config.php.

    If you need any assistance feel free to ask, hope this helps!

    in reply to: Builduing a linux service that gets weather data #23813

    Samer
    Keymaster

    Oh okay I understand what you are doing now! Yes absolutely you can rip out the manual mode. It is very easy and uses very little code. It was the first thing I added to my web app, actually. If you need help grabbing the specific functions for the manual mode let me know. Inside sprinklers.php you will find a series of “pages” the one with id manual is the page you would need along with the header and script sources at the bottom of the body. Inside main.php you would need the functions get_stations, make_list_manual, is_mm, send_to_oc, mm_on, and mm_off. Inside main.js.php you would need the event binder for the slider. I believe that is enough to have a fully working manual mode page.

    in reply to: Builduing a linux service that gets weather data #23826

    Samer
    Keymaster

    Also, what do you mean scheduling? Isn’t that what programs are? Just curious as to what else is left that could be added to the sprinklers.

    in reply to: Builduing a linux service that gets weather data #23825

    Samer
    Keymaster

    Your absolutely right by the way, without a controller you hit the time out a lot. I will consider that in the future. I also added a feature in the installer to verify the IP to help prevent timeouts by accident for unsuspecting users.

    in reply to: Builduing a linux service that gets weather data #23823

    Samer
    Keymaster

    Appreciate the suggestions! In my situation the OS is wired and in close proximity to my server thus the latency is almost nothing between the two. So far, I have noticed no problem in speed to be honest with you although I completely understand where you are coming from. I will consider using a database/cache but I really wanted to avoid it. Just to be clear my server already runs MySQL for other services so it would be no problem to use a database, personally. The way I see it, if the app is going to lag sending commands (waiting on the OS to send command) then it is probably okay to wait for it to load although for me personally the web app seems very responsive/fast.

    For my sake, have you tried the web app and if so are you experiencing lag? Would definitely help the direction I take the web app in. I will be honest though, I built the app for my father (Father’s Day is coming up soon after all) and he seems very happy with it (he even said it’s too responsive haha he was referring to the flip switches though) which is all that matters to me. But, if there is a problem I can fix I would be glad to!

    in reply to: Builduing a linux service that gets weather data #23821

    Samer
    Keymaster

    I am using file_get_contents but I set a global timeout. I was debating curl but decided that some installations might not have curl support (I don’t think it is part of the base PHP package) so I decided to stick with file_get_contents for now. I did refactor my code to call file_get_contents from my own function that way I can easily change how I wish to interface with the OS in the future and also add more error catching, etc.

    Thanks for the code post!

    in reply to: Builduing a linux service that gets weather data #23818

    Samer
    Keymaster

    I honestly haven’t given it too much thought yet been focused on packaging up the web app as a whole right now. But, I was interested in having the PHP (which is already running on a crontab) to maybe poll the weather and at the very least displaying that to the user within the app. Of course, it would be very neat if the PHP could activate a rain delay if it noticed the weather forecast predicated heavy rains (similar to the function of a rain sensor).

    Right now, I am not using any storage for my app. It functions by grabbing the data from the OpenSprinkler. Also, I am not using a Raspberry Pi so I am not having to interact with the OpenSprinkler at a hardware level. With how efficient the logging system works I want to avoid tying a database to this setup to be honest with you. What I have in my head is simply checking at a set time (ex. 11PM) the weather for tomorrow. If it’s (and im making this up) >80% chance of rain automatically telling the OpenSprinkler to trigger a rain delay of 24 hours. Something simple. I was also thinking of adding a weather button on the main menu which just uses the location setting on the OpenSprinkler to grab weather data and display it in the iPhone. Of course, if your using an iPhone you can simply pull down your notification center and see the weather which is why that particular feature has remained a low priority.

    I also think the PHP could fire off an email if it triggers an automatic rain delay just to inform the user something happened (of course could be disabled).

    Thank you for the detailed post by the way! The research on which API’s is helpful as is the array structure’s and methods. I will update if I get some time to play with the weather frontend and let you know!

    in reply to: Builduing a linux service that gets weather data #23814

    Samer
    Keymaster

    I am planning on incorporating something like this into my web app and would love to know if you have made any more progress and subsequently planning on releasing your code. Would save me the trouble and the collaboration could only help.

    Thank you in advance, also the code for the app I am making is available at: https://github.com/salbahra/OpenSprinkler-Controller

    in reply to: Mobile Web App with Screenshots (Updated) #23847

    Samer
    Keymaster

    I added an installer to streamline the process.

    If you already have a web server this can be deployed in two easy steps:


    mkdir -m 777 /var/www/sprinklers

    git clone https://github.com/salbahra/OpenSprinkler-Controller.git /var/www/sprinklers

    If you do not have git installed you can simply grab the zip and extract it. Download here: https://github.com/salbahra/OpenSprinkler-Controller/archive/master.zip

    The permissions are to allow the installer to make new files inside the directory (config and log files). Your welcome to chmod 644 after the install process.

    All you have to do is put the files in your web server’s directory and open the website! The default configuration options are already filled out at the bare minimum you just need to put a user name, password, and your OpenSprinkler IP and password.

    Once the install is done a popup will come up notifying you of an error or success. There isn’t much info if it fails at this point but most likely a permission error somewhere. Also, the script automatically adds the crontab to log valves for you, if it can.

    Some screenshots of the install process:

    Enjoy!

Viewing 25 posts - 1,676 through 1,700 (of 1,705 total)