OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Interval program with new plugin architecture

  • This topic is empty.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #22820

    Dan in CA
    Participant

    The latest rev of the Python interval program on GitHub includes a new plugin architecture.

    The GPIO pin definitions and the URLs list from the ospi.py program file have been moved into separate modules which, along with gv.py, can be imported by plugins to enable sharing of features. There is a new “plugins” folder where any new plugins should be placed. A couple of example plugins are included to give anyone wanting to add new features to the program a starting point.

    One of the plugins included with this release is named “mobile_app.py” which was written to work with Samer’s new all javaScript mobile app. It is also an example of how to access the interval program’s internal settings.

    There is a very simple plugin named “relay” which demonstrates how to access the GPIO pins. You can activate this plugin by appending /tr to your OSPi’s URL. The plugin toggles the on-board relay, found on newer OSPi boards, on for 3 seconds and then off. Even if you don’t have anything connected to the relay you should be able to here it click on and off.

    The third plugin is called “monthly_adj.py”. It is designed to automatically adjust the amount of irrigation applied on a monthly basis. This plugin uses a non-standard Python module “apscheduler” which is like a Python version of cron and allows scheduling of events from inside a python program. This module must be installed on your Pi in order for the plugin to be fully functional. You can however check out the plugin by appending /ma to your OSPi’s URL. You can set a percentage of adjustment for each month of the year. I came across a web tool for creating irrigation schedules that will give you a month-by-month percentage adjustment for you zip code:
    http://www.rainbird.com/rbts/tutorials/RunTimeCalculator/index.htm
    You will need to enter your zip code and then move to the very last page to see the monthly adjustments. I’m sure there are other sources for this information. Once you have a monthly adjustment set up and saved the plugin can automatically make the adjustments on the first day of each month. If you just want to view the plugin’s data entry page and then return to the program’s home page just click your browser’s back button.

    I have not implemented any buttons for accessing these plugins in the main program due to current changes taking place in the program’s UI and the fact that some, like the mobile_app plugin, don’t need user access.

    The add-on feature originally included in the Interval program should be considered deprecated at this point. It resulted in circular dependencies and other problems. Also users interested in adding features to the program seemed to have difficulty using it.

    For anyone who is using an add-in created from the original implementation, the code for loading add-ins is still in the program but commented out starting at line ~23.

    It is my hope that users will contribute plugins and we can create a repository for them. This project is really a Do-it-yourself and share kind of thing and I look forward to see what you come up with.

    Sorry for the long post. I plan to add a section to the Rayshobby wiki with further details about creating plugins.

    Dan

    #26402

    nayr
    Participant

    thanks dan; this is exactly what I was needing for doing some additional automation/timing alongside the sprinklers.. from a glance it looks like a piece of cake now.

    the adjustment plugin sounds really awesome; I’ll definitely check it out.

    #26403

    nayr
    Participant

    Question Dan, why does the python interval program use a hardset timezone offset and not use the OS’s supplied one? If one were to run this year round to automate other tasks than yard irrigation, it’d be great if there was one less thing around the house that had to be adjusted twice a year for daylight savings time 👿

    If we must be subjected to this insane bi-annual time shift, at least our more intelligent devices should be smart enough to compensate for some of the insanity. 😆

    #26404

    Dan in CA
    Participant

    Originally the program used the OS’s time and had auto daylight adjustment but that caused problems for users in other parts of the world. I have tried to keep this as international as possible.

    Perhaps there is a way to add an option to switch between time modes. I’ll give it some thought.

    Dan

    #26405

    nayr
    Participant

    hrmm, I always figured tz-config was pretty accurate with as often as they update it; I wonder if people simply did not know how ot change there OS TimeZone; if so it’d be better to fix it with documentation and not revert features.

    #26406

    Dan in CA
    Participant

    Good point.
    In fact, by definition a “smart controller” is one that does not require human intervention. I’ll look at restoring the old behavior if it wont break anything major.

    Dan

    #26407

    nayr
    Participant

    awesome thanks, I went ahead and appended the OSPi and OSBo wiki pages to include a small blurb about configuring the OS timezone.

    #26408

    nayr
    Participant

    ok so I have an issue where I restart OSBo; usually forcibly by watchdog timer, pulling power because hung on boot, etc.. its not 100% consistant but when the system boots back up and gets to the userspace (the moment I can login w/ssh) my first station kicks on automatically; I presume this is when the interval program is starting up.

    I hit it several times now; almost bricked my self with a bad watchdog timer config rebooting in a loop.. every few reboots the valve would come back on until I went out and pulled the common wire; then with some fast typing fixed my watchdog before it reset.. (good news is it shut back down when the watchdog timer reset the system a few moments later, as one would hope)

    The interval program has no idea that station 1 is on; but if I press ‘stop all stations’ the station shuts down, without manual intervention I assume it will run until the next schedule starts.

    Not sure what is triggering this, I am thinking a stop_stations() needs to be called when the interval program is initialized just to ensure all valves are closed incase something is awry.

    #26409

    Ray
    Keymaster

    @dan: cool, thanks for releasing the new plugin architecture!


    @nayr
    :

    my first station kicks on automatically; I presume this is when the interval program is starting up.

    Does the station kick on even when no program is running? If it stays on that’s unusual.

    I’ve noticed that on OSBo during system reboot the valves will pop very momentarily. I have yet to investigate what caused this. It’s known that 74HC595 shift register initializes to undefined states, that’s why there is an output enable (OE) signal line which controls when the output from the shift register will become ‘visible’. Before the OE pin is pulled low, all outputs are disabled (i.e. high impedance state). That’s why upon reset, all valves will be released, and no valve will be activated until the software pulls the OE pin low.

    On the microcontroller-based OpenSprinkler, the shift register gets refreshed every second (by calling the apply_station_bits function). I assume this is the same in the Python program. If this is the case (and station_bits are all initialized to 0 at the beginning), it should turn off all valves when the program starts running. Dan can probably confirm this.

    #26410

    Dan in CA
    Participant

    The function set_output() in the Python program (~line 290) is equivalent to the svc.apply_all_station_bits() function in the micro controller version.

    It may be a good idea to explicitly clear everything on start up. Although when the related vars are first defined they are all in a cleared state anyway.
    Adding a stop_stations() line just before the timing loop stasrts (~line 973) might help. Actually maybe set_output() instead of stop_stations() would do the trick.

    Dan

    #26411

    nayr
    Participant

    Ive put wget -q “http://127.0.0.1:8080/cv?pw=&rsn=1” -O /dev/null into my rc.local to see if it shuts the valves off on the next occurrence, I’ll also test w/out interval loading and see if its hardware.. but I’d think it’d occur instantly, before beagle is booted?

    #26412

    ckmiecik
    Member

    So this might be the solution to what I want out of my sprinkler timer. I want a nice full featured timer for my 3 zones but I also would like to add motion sensor inputs to trigger corresponding zones to try and keep the neighborhood animals from pooping on my lawn. could there be a module easily written which says if pin “x” gets signal from PIR sensor then start zone 1 for 30 seconds? are there enough useable pins on my pi for three zone outputs and three zone PIR inputs…or would this be better accomplished on my Arduino? I’m not really good at programming but i’m learning through projects like this…any help would be greatly appreciated.

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

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Interval program with new plugin architecture