- This topic is empty.
April 5, 2014 at 1:16 am #22820
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.
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:
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.
DanApril 6, 2014 at 12:45 am #26402
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.April 8, 2014 at 5:41 am #26403
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. 😆April 8, 2014 at 3:29 pm #26404
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.
DanApril 8, 2014 at 7:15 pm #26405
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.April 8, 2014 at 9:09 pm #26406
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.
DanApril 8, 2014 at 10:29 pm #26407
awesome thanks, I went ahead and appended the OSPi and OSBo wiki pages to include a small blurb about configuring the OS timezone.April 8, 2014 at 11:25 pm #26408
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.April 9, 2014 at 2:56 pm #26409
@dan: cool, thanks for releasing the new plugin architecture!
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.April 9, 2014 at 4:18 pm #26410
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.
DanApril 9, 2014 at 7:37 pm #26411
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?April 22, 2014 at 7:20 pm #26412
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.
- You must be logged in to reply to this topic.