For my first project I wanted to use a Rpi to open and close my garage door. I knew a majority of the time, members of my household would be using this via Alexa. With it being my first project, I really struggled to find (and understand) a comprehensive solution and wanted to share what I finalized on.
Many thanks to all the people who actually code and took the time to share! I tried to link to everyone’s work below.
Raspberry Pi setup: I bought a Rpi 3 model b (probably overkill) with n00bs installed Raspbian Jessie. I ran into a bunch of problems because of Python and PHP being upgraded and a lot of solutions used older code. If you know what you’re doing you can upgrade them, but that wasn’t me. I finalized on using the Webiopi solution… with a couple of changes…
There was also a patch I had to run to get the webpage working.
I’m struggling getting the service to auto start on reboot per the directions. I did find a command to update rc.d but it’s still not 100%. I’ll have to dig into that alittle more.
I opted to use the modified Smartapp and Device handler by Kalltech because he fixed a couple of device id errors the original solution had and he also added a contact sensor… something that was important to me as I had magnetic contact sensors I wanted to include.
I had a problem where all of my sensors and switches were opposite (open vs closed and on vs off). I know very little coding and it took a little trial and error.
On the contact sensor device handler I had to flip the 0 and 1 on lines 83 and 86
On the relay I had to make two changes.
On the device handler I had to flip the 0 and 1 just like the contact sensor on 83 and 86. In the SmartApp I had to flip the 0 and 1 in the array on line 437 and 447
My goal was to use a slick app that would sync the contact sensor with the simulated garage door. My problem was that Alexa doesn’t allow the control of doors and locks (probably for good reason). It would see that simulated garage door and refuse to interact with it. Regardless, I still have it setup incase I want to use it in the future.
My endgame was to use simulated switches and Core Pistons to make my relays momentary and to make sure that when I said “Open”, the garage doors would only open when in a closed state. After all was said and done, I ended up with 8 “things” in Smartthings for my two garage doors.
Garage Door Sensor 1 (Webiopi contact sensor for the garage door)
Garage Door Sensor 2 (Webiopi contact sensor for the 2nd garage door)
Garage Door Switch 1 (Webiopi switch for my first relay connected to the garage door)
Garage Door Switch 2 (Webiopi Switch for my second relay connected to the 2nd garage door)
Garage Door 1 Open (Simulated switch acting as my main trigger to open the 1st garage door, controlled by my Piston)
Garage Door 1 Close (Simulated switch acting as my main trigger to close the 1st garage door, controlled by my Piston)
Garage Door 2 Open (Simulated switch acting as my main trigger to open the 2nd garage door)
Garage Door 2 Close (Simulated switch acting as my main trigger to close the 2nd garage door)
My pistons followed this formula. “Simple Piston” type.
If “Garage Door 1 Open” Changes to “Open” and “Garage Door Sensor 1” is “closed”
Then “turn on” “Garage Door Switch 1” then “Turn Off (delayed)” after “1000ms”. (If I tried to make it shorter it didn’t seem to consistently fire the relay). Then “Turn off” “Garage Door 1 Open”
Else “Turn Off” “Garage Door 1 Open”
I created one for both opening and closing both doors.
Now if I hit “Garage Door 1 Open” in smartthings, my first garage door opens. If I press it again, nothing happens. I then went to the Alexa app and discovered my new smarthome devices. I then went to “routines” and created a new phrase “Open Sesame” and tied it to “Garage Door 1 Open”, and another for “Close Sesame” tied to “Garage Door 1 Close”.
Thanks to everyone in the forums that helped me out when I had questions and thanks for people who share their code, I would never have been able to do this from scratch!