OpenSprinkler Forums Comments, Suggestions, Requests Show next start time for sprinklers in main display

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #44464

    skyynet
    Participant

    I’d like to show the next start time of each sprinkler and if it will run or not (because of weather forecast or rain sensor) in my home automation display.
    Thus I read the values via OpenSprinkler’s API controller variable ps which shows program index (pid), remaining water time (rem) and start time (start). I also read the rd variable to check if the station will run.

    Unfortunately the content of start is not shown if no station is running.

    Could this behavior be changed to have start always show the next start time? I see no disadvantage.
    Showing it in the main web page of OpenSprinkler would also be nice.

    #44482

    Ray
    Keymaster

    Did you check the Program Preview feature? This is available in the app / web interface. From it you can see when the next station run will start, and the program preview does take into account weather.

    #44484

    skyynet
    Participant

    Yes I know that I can see it in the program preview screen on web / app. I just query the values via API with PHP and I think it makes no sense not to show the next running time in the main “sprinklers” screen while showing it when ONE sprinkler is active.

    #44502

    Ray
    Keymaster

    It’s a bit tricky for the controller to keep track of this variable and report it. The reason is that this would require the controller to search through time to find the next program start time, and the next start time might be days away. Also it has to do this repeatedly to accommodate dynamic events. The preview is much better suited for this because it runs software simulation of the scheduling algorithm in your browser / on your phone, so it eliminates the need for the controller to run this computation.

    Technically the controller does NOT represent program events as a calendar (that would require too much resources that the microcontroller-based OS does not have). Instead, every minute it uses the current time to check against the programs to find out whether the program should run or not. To find out the next start time, the controller needs to step through time minute after minute to find out the next time a program would run, which is computationally expensive.

    #44554

    skyynet
    Participant

    I see. So I have to read jp (start & dur) to get the start time and duration and calculate the next time by matching with current time.

    #44578

    David
    Participant

    Hey,

    did you have a working function for this?

    Can you post it, please.

    Thanks.

    #44602

    skyynet
    Participant

    Well, I have a PHP code that seems to work but want to test it first for some time.
    Also the code might make a structured oo programmer’s head explode.
    I’ll post it when I have tested it a little. Just wrote it until now.

    Currently looks like this:

    Attachments:
    #44611

    David
    Participant

    looks god,
    it finds the next startingtime.

    if it works fine: just post it. 🙂 so i can add this to the pebble App.

    #44712

    skyynet
    Participant

    I verified it a few days and it seems to work. My code will definitely not please structured oo programmers but it works and sometimes it’s easier to optimize things than create them in the first place. I also commented it so it should be readable somehow. This sprinkler status display is part of my infoscreen which runs on an iPad 1 in our house.

    sprinkler.php creates the display and loads sprinkler_content.php periodically.
    Due to my personal usage the script only shows three stations on two programs which run in the morning and evening. My stations run 1,2,3 in the morning and 1,2,3 in the evening. If you have more stations, you’ve got to add them to the code or query the api for the max number of stations and loop through. The same happens for the programs. If you have more than two programs you have to adapt the script.

    I have setup a rain delay when the weather report indicates rain. The script queries the rain delay bit and changes the big image to one that shows a closed sprinkler with rain above. While running the small water drops in front of each station are animated and the remaining watering time is shown.

    Of course you have to change the URL and the OpenSprinkler password in the beginning to reflect your home setup.

    Have fun!

    Attachments:
    #44768

    David
    Participant

    Nice, thank you.

    i need some day to look a the code.

    Maybe i impelment this in the winterholidays. 🙂

    You could add this to the OpenSprinkler App.

    Or with the your running PHP version you could wirte a module for a SmartMorror (like https://magicmirror.builders/)

    #44783

    skyynet
    Participant

    As I don’t use a SmartMirror but only an iPad I don’t need to rewrite my code. As mentioned it depends on some assumptions which will not fit everyone. But maybe some parts of the code are interesting if someone wants to write his own. If someone optimizes parts (which is definitely possible!) I’m happy to read about it.

    #65719

    johnny
    Participant

    Just uploaded a MM module that supports OpenSprinkler. It connects to the demo.opensprinkler.com by default. Still needs lots of enhancements but it works.

    https://github.com/johnny-co/MMM-OpenSprinkler/

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Comments, Suggestions, Requests Show next start time for sprinklers in main display