June 23, 2014 at 1:02 am #22987
This simple plugin will open and close up to two garage doors and detect whether the doors are opened or closed. Everything is handled through custom URLs and there is a very basic status/control HTML page. Python is not my first language so I’m open to any suggestions and improvements.
My main goal was to have access to URLs to control the garage through programs like Tasker for android. Now I can say “Are the garage doors open?” and I’ll get a reply. I can also tell it to “Close the big garage door” and it will.
Relays – about $6 for a 2 relay board at amazon (I’m using the 4 relay version for easy future expansion). Most garage door openers have a physical switch somewhere inside the garage. There is a wire that runs from this switch to your opener. You can run a pair of wires from each relay and connect them directly to your opener at the same place that the interior button is connected. Or you can also splice into the wires that are between the opener and the button. Each opener is a little different.
2 Reed Switches – about $6 each – These are attached to each door (one part of the switch is attached to the door and the other is stationary and attached to the rail that the door slides along).
I didn’t use the built in relay because I have an older OSPi board that doesn’t have it and I have two garage doors. Normally, the RaspPi draws its power from the opensprinkler board through the GPIO pins. I needed access to the 5V GPIO so I disconnected it and I am powering the RaspPi through its micro USB port.
GPIO BOARD PIN #
2 --> Relay's VCC
4 --> Relay's Ground
12 --> Relay 1 trigger
16 --> Relay 2 trigger
18 --> Reed switch 1
20 --> Reed switch ground
22 --> Reed switch 2
I wanted this to be a true plugin, so there is no need to modify any existing files. Just drop the garages.html into the template folder and garagecontrol.py into the plugins folder. Remember to set its permissions to be executable otherwise it won’t be loaded. This works on version 2.0 – I’m not sure if it will work on earlier versions.
You can change the defines in the top of the garagecontrol.py file to change the GPIO pins and many other settings.
Several custom URLs are included:
/gs1 Checks garage door 1 and returns "open" or "closed"
/gs2 Checks garage door 2 and returns "open" or "closed"
/gp1 "Presses" the garage door 1 button
/gp2 "Presses" the garage door 2 button
/gi Brings up the garages.html status page
Since this will open and close your garage doors, security is very important. For now I’m using the verifyLogin code from OSPi so you need to be logged in for it to work (or include your password in your URL like this http://yourOSPiAddress:8080/gp1?pw=yourpassword). If you are connecting to your OpenSprinkler from outside your LAN, please make sure it is secured with a VPN or other security measure.
I’ve thrown this together relatively quickly, so here are some issues:
At boot, the pi sends power to relays (opening or closing the doors). It’s not enough to activate the relay so the door doesn’t open, so it’s not a problem but it should be fixed sometime.
The garages.html is extremely basic. It shows the current status and lets you click links to activate the button. It’s not pretty. Someone really needs to rewrite this.
No open/close logic. Currently it just presses the button, so all my logic is handled by tasker.
There are probably more things to add or iron out, but like the title says – this is a beta.
This is provided as-is, but is working well for me. I’ll post some pictures of the hardware in the next week or so.June 24, 2014 at 2:24 am #27268
V.02 – Added code to support the Interval 2.01’s new menu system.June 25, 2014 at 2:54 pm #27269
I needed access to the 5V GPIO so I disconnected it and I am powering the RaspPi through its micro USB port.
How did you do this?June 25, 2014 at 3:50 pm #27270
How did you do this?
I’m on an earlier version of the OSPi board (1.2?). With that board all the gpio pins are accessible. There is a two wire cable that goes from the GPIO (board pins 2 – 6 I think) to the OpenSprinkler board. Disconnecting this cable cuts the power to the RaspPi so you just connect a MicroUSB cable to it and power it that way.
Unfortunately, the newer boards flip the RaspPi over and all of the GPIO pins are plugged directly into the Opensprinkler board. I don’t have access to a newer board, but I think they don’t give you access to the 5v pin anymore. One workaround would be to disconnect the RaspPi, flip it back over, and use jumper cables to connect it to the Opensprinkler board.I think you would only need to jumper the odd pins from 1 through 15. The even pins are only used to power the pi on my board.
I’ll try to post some pics tonight.June 25, 2014 at 9:27 pm #27271
I don’t have access to a newer board, but I think they don’t give you access to the 5v pin anymore.
That’s incorrect — on OSPi v1.4, all RPi pins are mapped out in the pinout area. Please see the user manual page 9:
http://rayshobby.net/docs/ospi14_manual.pdfJune 25, 2014 at 10:39 pm #27272
Thanks for the info Ray. It was hard to tell if the 5V was still available. In the manual it looks like the 5v pins are still being used to power the pi (like my board). Is that correct?
If so, is there any way to access 5v to power a separate relay?
btw… The OSPi is really great. Thanks for making it!June 25, 2014 at 10:47 pm #27273
I guess when you say ‘if the 5V was still available’ you mean to provide 5V from an external source like microUSB cable, and not use the internal 5V provided by OSPi? There isn’t a very easy way to achieve this, probably the simplest is to remove the PTC fuse (the green component on close to the bottom of the circuit board. Once the fuse is removed, the internal 5V is cut off from the rest of the circuit.
On a related note: OSPi v1.4 has a built-in relay and all three relay pins (CO, NO, NC) are mapped out on the board. If you just need one relay, it’s pretty convenient to use the built-in relay (controlled by GPIO pin 15).October 8, 2014 at 8:16 am #27274
Hello Virtus, for me your plugin is perfect, i’ve used so far with satisfaction 😉
Now with the latest release 2.1.1 is not available in the plugin menu.
Can you fix this please, i think that need some changes and I have a little knowledge of python 🙁
thanks in advance!
PierantonioOctober 20, 2014 at 2:52 am #34071
where can I download your plugin?
LouisOctober 20, 2014 at 3:37 pm #34079
Most attachments didn’t migrate over to the new forum and unfortunately previous attachments are no longer present.
Hopefully, Virtus can re-upload otherwise I will look and see if I can recover a working copy of the plugin.October 30, 2014 at 9:12 am #34313
Anyone able to upload a copy of this plugin, or better yet, start a git project with it?October 30, 2014 at 6:14 pm #34321
Fortunately, Dan had a copy of the plugin saved and has emailed it to me. I am now attaching it here for others to use however since it isn’t tested for the latest copy of OSPi, I am not sure if it will find it’s way into the main repository.
Attachments:October 31, 2014 at 4:02 pm #34338
Hello, i’ve tried to modify this plugins with no success.
I’m newbie in python, and i don’t know where i put hands 🙂
I’ve modified only the garagescontrol.py in the import classes, now the plugins is visible in the list “plugins” of the web interface, but when in press the button i have this error message “Internal server error”
I hope someone is able to adapt to the new graphical part, i would be very grateful as 🙂
Virtus, where are you? we need your help 😛November 1, 2014 at 9:20 pm #34351
To get some more information about what went wrong, open a terminal session on the Opensprinkler Pi.
Then cd to the /home/pi/OSPi directory
Type sudo service ospi stop
sudo python ospi.py
This will allow you to see the console log messages. You will probably find some typo’s in function names or syntax errors.
- You must be logged in to reply to this topic.