OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Interval plugin: Auto-Program – v2 release now available!

Viewing 25 posts - 1 through 25 (of 35 total)
  • Author
    Posts
  • #22926

    scottsh
    Participant

    After a couple weeks of testing and seeing it work correctly, I’m ready to declare the Auto-Program plug-in early Beta release ready for use.

    I don’t release this beta lightly. If there is a bug, it can waste a lot of water, kill a lot of plants, and cost you a lot of money. This is released without warranty. I’m also going to make this available primarily as a github clone to reinforce that this version isn’t as secure as the core internval program. In the not too distant future, I’ll release it as a pure plugin that can be dropped into your existing interval directory.

    To install, create a new directory on your OSPi and clone the github repository into it. Then, you need to shut down your currently running interval program before starting this one.

    You can clone the repo using:

    git clone https://github.com/scottshaffer/OSPi.git

    Once the files are landed, manually start the software from its directory using:

    sudo python ospi.py

    To get started, browse to http:///auto. You will need to configure your zone settings and weather data before turning it on.

    Also, this version still includes the simulation capability. If you turn simulation mode on, access to the GPIO pins that drive the triacs and ultimately the solenoids is disabled. This tricks the entire interval program into thinking it is running when it is not. No actual sprinklers will be turned on in this case, through any mechanism (programs, manual control, etc.) although it will act as if it is working.

    #27001

    Ray
    Keymaster

    Cool, thanks for contributing. If I understand it correctly, this auto-program is in the context of the following thread, is that right?
    viewtopic.php?f=28&t=564

    #27002

    scottsh
    Participant

    Yes, it is. It uses an ‘inches per week’ approach that includes the amount of rainfall received, the amount of water a given zone can irrigate, and the run-off limit for each zone.

    With that information, each day it determines the amount of water needed to keep the ‘inches per week’ of water at the specified level.

    It works, but I’m not sure it is as optimal as the ET method DanTripp has been discussing. I have his simulation program and want to run it against the ‘inches per week’ approach to see if one is materially better than the another.

    #27003

    scottsh
    Participant

    Just FYI, I made a small bug fix that addressed a problem with the weather history data. It was growing forever in the file instead of being trimmed to the specified number of days to watch.

    #27004

    scottsh
    Participant

    I wanted to provide a small update in that I’ve fixed a couple of minor bugs (the software didn’t handle abbreviated month names – a problem that wasn’t seen in May.)

    However, all told the main algorithm is running great – it’s watering correctly based on desired in/week, correctly handling rain amounts, and overall is keeping my lawn alive with what I think is minimal water.

    Next up on my list of improvements:
    – Get drip irrigation support working (gal/hour instead of in/min)
    – Get metric weather data from wunderground working properly
    – Ability to pull point forecast data from NWS and suspend watering if forecast precipitation chance > than a specified chance over the next 24 (or 12?) hours.

    However, I’m also looking at DanTripps ETO simulation to determine if that is appreciable better. I suspect it is, but I haven’t had time to prove it. I did prove out that in time of zero rain, the amount of irrigation used by both methods are the same – that’s a good “upper bound” test, but now I have to simulate rainfall and see if ETO ends up watering more efficiently.

    #27005

    eecyclone
    Participant

    I am getting an internal server error when I try to navigate to the http:///auto website. Any ideas?

    Also, how soon will you be making this available as a pure plugin? I would like to try it out in addition to interval 2.0 that was released yesterday.

    #27006

    eecyclone
    Participant

    Do you have any updates on using this with the new 2.0 software?

    Thanks!

    #27007

    scottsh
    Participant

    I was out on vacation for a couple of weeks, but now that I’m back I’m looking forward to trying out 2.0 myself (I haven’t had time yet!) and getting the plug-in to work with it. Stay tuned!

    #27008

    scottsh
    Participant

    Auto-Program is now updated to v2 support.

    As always, you can sync from my github at https://github.com/scottshaffer/OSPi.git. It includes a full up to date copy of Interval v2. That said, this is making me want to think about how to to create some sort of installer so that it can be added to your existing OSPi without forcing you basically reinstall.

    If you want to keep your existing settings, copy over the ~/OSPi/data directory from your existing installation to this one and you won’t have to start over with passwords/station settings.

    Scott

    #27009

    richpuch
    Participant

    Scott,

    Having problems testing your code here is what I get on start-up:

    sudo python ospi.py
    The Python module apscheduler could not be found.
    Setting water level to 100%
    The Python module apscheduler could not be found.
    Checking rain status…
    No rain detected
    Ignoring exception while loading the zone_settings plug-in.
    name ‘sched’ is not defined
    Ignoring exception while loading the wx_settings plug-in.
    name ‘sched’ is not defined
    Ignoring exception while loading the auto_program plug-in.
    name ‘sched’ is not defined
    plugins loaded:

    Starting timing loop

    http://0.0.0.0:8080/

    Here is what I get when I go to http://192.168.2.30:8080/auto

    Traceback (most recent call last):
    File “/home/pi/OSPi/web/application.py”, line 239, in process
    return self.handle()
    File “/home/pi/OSPi/web/application.py”, line 230, in handle
    return self._delegate(fn, self.fvars, args)
    File “/home/pi/OSPi/web/application.py”, line 416, in _delegate
    mod = __import__(mod, None, None, )
    File “/home/pi/OSPi/plugins/auto_program.py”, line 282, in
    import wx_settings
    File “/home/pi/OSPi/plugins/wx_settings.py”, line 35, in
    @sched.cron_schedule(hour=1)
    NameError: name ‘sched’ is not defined

    192.168.2.114:58094 – – [27/Jul/2014 16:52:44] “HTTP/1.1 GET /auto” – 500 Internal Server Error

    Any ideas?

    Thanks
    Rich

    #27010

    scottsh
    Participant

    Yes you need to add the apscheduler module which allows the app to run every day at the specific time to setup the auto-program for that day.

    Use this command to install the extra module.

    sudo pip install apscheduler==2.1.2

    UPDATE: fixed to specify the version which is now required since apscheduler updated to v3

    #27011

    eriberg
    Participant

    I get an internal server error when I try to run the auto program:

    192.168.0.115:56582 - - [27/Jul/2014 23:16:58] "HTTP/1.1 GET /uap" - 303 See Other
    192.168.0.115:56582 - - [27/Jul/2014 23:16:59] "HTTP/1.1 GET /auto" - 200 OK
    precip_today_in 0.00
    Traceback (most recent call last):
    File "/home/pi/OSPi/web/application.py", line 239, in process
    return self.handle()
    File "/home/pi/OSPi/web/application.py", line 230, in handle
    return self._delegate(fn, self.fvars, args)
    File "/home/pi/OSPi/web/application.py", line 420, in _delegate
    return handle_class(cls)
    File "/home/pi/OSPi/web/application.py", line 396, in handle_class
    return tocall(*args)
    File "/home/pi/OSPi/plugins/auto_program.py", line 219, in GET
    runAutoProgram()
    File "/home/pi/OSPi/plugins/auto_program.py", line 115, in runAutoProgram
    if (t.day()%2)==0:
    TypeError: 'int' object is not callable

    You’ve done great work to get this going and I’d really like to try it out. Thanks for your effort.

    I’ve since found that it will work if I turn off the restrictions (I had set it to Odd days only). I have a question about how it calculates the duration for the watering. I put in 1.2 inches per week and set every other day for watering. The system set the duration to 136 minutes for each sprinkler. It ran the scheduler starting at 136 minutes per sprinkler. I assumed it would divide this amount by the number of days in the week, for example – 136 minutes over the upcoming week (Monday – 34 minutes, Wednesday – 34, etc.). It seemed to schedule just Monday at 136 minutes each zone.

    Thanks for any help you can offer.

    Erik

    #27012

    scottsh
    Participant

    Wow – great bug find! That bug has been in there since “day one”. All fixed, if you pull or freshen your clone, it will pick it up. Thanks a lot.

    To update your clone, execute the following from in the directory where you cloned the repository:

    git pull

    The code for determining the odd/even day watering schedule was obsolete and based on an earlier design that got refactored, but for some reason I missed handling the part when the actual watering is done. Which shows how much I tested odd/even watering lately. I’m really coming to wish I had an automated test setup.

    #27013

    eriberg
    Participant

    Thanks for fixing that. I’ve set the values low for the max water for runoff and I believe I have it set up correctly. I’m wondering if you’re plugin takes the forecast into account (it seems like it doesn’t), and if not, can it be used with the weather adjust plugin to delay watering or will that cause a conflict? I’d also like to try the monthly adjust plugin, but I don’t know if plugins are designed to work together.

    Thanks for sharing your work

    Erik

    #27014

    scottsh
    Participant

    The “Monthly adjust” plugin and this plugin don’t work correctly together yet. It’s on my list to add though.

    The amount actually watered does get adjusted by the % set but the automatic algorithm will keep trying to water up to the entered Precip rate. I need to adjust that based on the monthly adjustment settings.

    Also, this is designed to work with the newly developed Weather Adjust plug-in. That plug-in needs to get forecast delay support added. This is also on my list.

    I’m currently working on adding drip irrigation support. The actual code isn’t that hard, but the UI code to swap the units from in/hr to gal/hr on the radio select is proving to be challenging for me. I’m learning a lot though.

    #27015

    scottsh
    Participant

    FYI – I just added and enabled support for drip irrigation systems. Pull a down copy if you’re interested in seeing how that works.

    #27016

    richpuch
    Participant

    Thanks for the tip on the apscheduler. I followed the wiki instruction and went ahead an installed the apscheduler and still see errors…

    The Python module apscheduler could not be found.

    I see the module in /usr/local/lib/python2.7/dist-packages/apscheduler/

    ls /usr/local/lib/python2.7/dist-packages/apscheduler/
    events.py executors __init__.pyc job.pyc schedulers util.py
    events.pyc __init__.py job.py jobstores triggers util.pyc

    But for some reason ospi.py is not finding it…

    I looking into the plugin files, but nothing really jumped out at me…

    Any recommendations?

    Thanks
    Rich

    #27017

    scottsh
    Participant

    Hmm, I don’t know what might be going wrong. Did you install apscheduler as root using sudo? Maybe its a permissions issue?

    #27018

    Samer
    Keymaster

    You need version 2 not 3 of APscheduler.

    #27019

    richpuch
    Participant

    Guys,

    Thanks for the help, I installed apsheduler v2 and it fixed my issues:

    sudo pip install apscheduler==2.1.2

    All loaded nicely and I’m able to get to the auto-program. Gonna play with it now.

    Thanks again
    Rich

    #27020

    fbret
    Member

    So I installed your excellent auto-plugin a week ago…
    I did have an issue with apscheduler that I had to downgrade to 2.
    I did remove all scheduling constraints and everything looks great – except that the auto-scheduler never turned a single valve on all week. Being that I am in California and it has not rained in a couple of months, that’s very surprising!

    How do I diagnose / see that the scheduler is working? It seems that it is calculating the deficit accurately, but nothing shows up in the calendar or the logs.

    Thanks

    -Fred

    #27021

    scottsh
    Participant

    Here are a few things to check, we’ll get this figured out!

    – First, on the Zone Settings page, do you have the zones enabled for automation that you want automated?
    – Second, on the Auto Settings page (the main page) is the auto programming enabled? Are there valid days selected? Is the start time set for a valid time?

    One way to test then to see if its able to auto-program is to click the ‘Run Auto-Program Now’ and see what gets scheduled.

    You should see ‘Program 97’ running against any zone that needs water.

    Oh one last thing – the system will never water less than 1 minute, so even if the ‘duration next run’ says it will run 0.43 minutes know that it won’t actually run.

    Scott

    #27022

    fbret
    Member

    Thanks!

    here are a few attachments…

    – zone settings seems to meet your requirement.
    – auto-program looks enabled and valid.

    When I click “run auto program now”, I get redirected to the OpenSprinkler Pi home page.
    If I go into the programs page, there are 0 programs showing and the calendar in the home page shows no scheduled plan for the next 48 hrs…

    It’s probably something real obvious!!!

    #27023

    scottsh
    Participant

    Thanks for the screenshots – they certainly looks right. Any chance the rain sensor detect is set to enabled somehow? That would cause this.

    However, for further debugging I would recommend the following. SSH into the OSPi board and do:

    cd ~/OSPi
    sudo service ospi stop
    sudo python ospi.py

    This will run ospi.py on the console and show you all the debug output.

    Then go to the Auto Program page and select Run Now and watch what happens on the console. What should happen is that all the zones should be scheduled and the system should start watering immediately. You won’t see anything on the Program page though – these aren’t real programs, just immediate zone scheduling. You should see that on the home page.

    To return to normal operation, press Ctrl-C on the console and execute:

    sudo service ospi start

    Scott

    #27024

    fbret
    Member

    Scott, thanks for the support!

    I did a git pull just to be sure!

    Rain sensor is not enabled in the options tab.

    Here’s the log running it from console:
    pi@sprinkler ~/OSPi $ sudo python ospi.py
    sudo: unable to resolve host sprinkler
    Checking rain status…
    No rain detected
    Setting water level to 90%
    2014-08-11 Getting rainfall history…
    auto_program: job scheduled runAutoProgram (trigger: cron[hour=’5′, minute=’0′], next run at: 2014-08-12 05:00:00)
    plugins loaded:

    Starting timing loop

    http://0.0.0.0:8080/
    auto_program starting automatic program loop
    192.168.1.20:59077 – – [11/Aug/2014 15:57:52] “HTTP/1.1 GET /rap” – 303 See Other
    192.168.1.20:59077 – – [11/Aug/2014 15:57:57] “HTTP/1.1 GET /” – 200 OK
    192.168.1.20:59078 – – [11/Aug/2014 15:57:57] “HTTP/1.1 GET /api/status” – 200 OK
    192.168.1.20:59077 – – [11/Aug/2014 15:57:57] “HTTP/1.1 GET /api/log” – 200 OK
    192.168.1.20:59077 – – [11/Aug/2014 15:57:58] “HTTP/1.1 GET /api/status” – 200 OK
    192.168.1.20:59077 – – [11/Aug/2014 15:57:59] “HTTP/1.1 GET /api/status” – 200 OK
    192.168.1.20:59077 – – [11/Aug/2014 15:58:00] “HTTP/1.1 GET /api/status” – 200 OK
    192.168.1.20:59077 – – [11/Aug/2014 15:58:01] “HTTP/1.1 GET /api/status” – 200 OK

    nothing 🙁

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

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Interval plugin: Auto-Program – v2 release now available!