Author Topic: Garage door project with IFTTT and Alexa  (Read 202 times)

rkinnett

  • Newbie
  • *
  • Posts: 6
Garage door project with IFTTT and Alexa
« on: February 18, 2017, 06:06:01 pm »
Hi all, 

I have been lurking these threads over the last year and gradually piecing together my own (yet another) garage door project.  I wanted to share my successes with the hardware, Arduino code, and integration with IFTTT and Alexa, hoping that at least parts of this project will be useful to someone.

I have posted all code from this project and a fairly comprehensive readme to github.

Project synopsis:  An Oak serves as a garage door monitor and controller.  An ultrasonic sensor mounted in the rafters of the garage and pointed downward senses whether the garage roll-up door is open or if a car is parked under the sensor.  IFTTT sends notifications to my phone when the door opens or closes, when a car arrives or departs, once per hour that the door is left open, and when the Oak is offline.  An Oak relay shield is connected to the garage door opener toggle signal, giving the Oak the ability to open, close, or toggle the garage door on demand.  The open, close, and toggle functions can be triggered through a custom http page, OakTerm, the Particle mobile app, IFTTT, or Alexa via a custom skill.  The custom Alexa skill lets the user ask Alexa to check door status or to open or close the garage door.



Hardware

Total cost:  ~$25



IFTTT Integration:
If you're not familiar with IFTTT, you should be.  It's a remarkably simple service which links various online services and data sources as "If This" triggers, and provides interfaces for "Then That" actions.  Particle has provided interfaces to IFTTT to work with devices through the Particle cloud.  You can create simple IFTTT recipes which monitor variables which your Oak pushes to the Particle cloud, or have IFTTT react to Particle.publish events.  You can also create recipes which, in response to any arbitrary trigger, will call your Particle cloud registered function.  I have set up recipes to send me a notification when the garage door opens or closes, when the garage door controller goes offline, and once per hour when the garage door has been left open.  Although I haven't tested it, you should also be able to use IFTTT to send a close command if the door has been open for an hour.  Lastly, I semi-sorta got Siri working, in an awkward way, through IFTTT.  You can tell Siri, "Text #open to Garage Door" (Garage Door is a contact you create with a phone number IFTTT provides to receive SMS messages), and IFTTT sends the open command.  See my github project readme for details about the IFTTT recipes.

Alexa Integration:
A custom Alexa skill allows me to vocally ask Alexa to check status or command the door to close through simple phrases such as "Alexa, ask My Garage Door if it's open", or "Alexa, ask My Garage Door to close".  The Alexa skill utilizes a Lambda function which receives JSON requests from Alexa, sends http requests to the Particle cloud, parses responses from Particle, and generates speech responses to be returned to Alexa.  I have posted the javascript code for the lambda function, as well as key components of the Alexa skill to github.

Thanks to Erik and his team and to all the die-hard supporters in these forums.

Please leave a comment if you found any of this useful, or if you have any questions.
« Last Edit: February 18, 2017, 06:31:42 pm by rkinnett »

exeng

  • Sr. Member
  • ****
  • Posts: 423
Re: Garage door project with IFTTT and Alexa
« Reply #1 on: February 18, 2017, 07:20:35 pm »
Very cool...

I have a similar setup without the IFTTT and Alexa integration. My setup uses the Oak integrated with Blynk, Particle and ThingSpeak.  Blynk allows me to remotely check status and close or open the door using a 5 digit code where the digits can be 1-8. I limited it to 8 possible digits to limit the Blynk button widgets used. Particle is just for status. ThinkSpeak is also for status but is persistent and keeps history. I use ThinkSpeak as a logging service for this and a few other things like, pool temp, weather and of course the garage door status. I have a TFT display connected to another Oak that pulls all of this status down to an in home display.

With regard to auto close, I have a light sensor (on a custom built relay shield), to determine day or night but it can be confused by a light on in the garage at night. I use it to implement an the auto close function (directly from the Oak). If the door is open for more than 4 hours during the day it closes automatically. If it is dark (night time) it auto closes after 15 minutes. Big word of caution when using an unattended auto close function... if there is no way to block a close due to an obstruction, well you know the rest. In other words, be sure that there is nothing across the threshold or in the path of the door when an auto close is initiated. Also, be sure to have another way in to the house. I've had occasions where I was outside with the garage door open for more then 4 hours and have seen it auto close without warning. On my TO DO list is some sort of audible warning of a pending close, say 5 minutes before closing and each minute thereafter.

Props: Very clever using the ultrasonic sensor for open/close, car present or not. I'm just using a single magnetic reed switch. I like your idea of the sensor.

My Oak is also mounted close to the opener high up in my garage, which has a very high ceiling. For anyone considering this application, if I had to do it over again (still can) I would bring the Oak down within reach for easy access. I've had to stand on top of a ladder (not a good idea) a few times to service the Oak.

Since I'm posting to Particle and ThingSpeak, I'll have to consider the IFTTT integration. I would love to get notification for door status changes.

Thanks for sharing this.

BTW: Big props for documenting this and your github page.
« Last Edit: February 18, 2017, 07:56:47 pm by exeng »

rkinnett

  • Newbie
  • *
  • Posts: 6
Re: Garage door project with IFTTT and Alexa
« Reply #2 on: February 18, 2017, 08:37:38 pm »
Thanks!

I haven't played with Blynk or ThingSpeak yet but now that I'm reading about them I don't know how I've gone without them.  I would love to log and plot data from my Oaks.  Thanks for the tip.  I also really like your idea of requiring a password; I think I'll add something like that.

I must have come across your warning about auto-closing in another thread.  The warning was well heeded; that's the main reason I haven't implemented that yet, though I might still try it.  I have a regular infrared interrupt sensor across the threshold, and I believe (will need to verify) the opener senses physical obstructions via current sensing, so maybe that pair of built-in safety features is sufficient protection against the Oak going rogue and closing with a car halfway in.

The range sensor idea wasn't mine originally, although the idea to report whether a car is present or not was mine.  I probably got the range sensor idea from this project, back when that project was just getting started.  Wow, that project has come a long way - they're selling $50 kits now.  Twice the price and half the fun.

Thanks for your general participation throughout this forum.  Your posts must have helped me through a half dozen issues along the way! 

exeng

  • Sr. Member
  • ****
  • Posts: 423
Re: Garage door project with IFTTT and Alexa
« Reply #3 on: February 18, 2017, 09:27:22 pm »
Wow, thank you for the feedback. I must say I probably get much more back than I give on this forum due to the generous participants willingness to help and share knowledge.  I just try to help where I can. You have set the bar on sharing with your an excellent documentation and github link. I've always wanted to venture into IFTTT and possibly Alexa. Your post will be my starting point.

Quote
Wow, that project has come a long way - they're selling $50 kits now.  Twice the price and half the fun.

If you just want a solution, than yeah one could buy it. But as you said, it's half the fun. I would say no fun. The journey is the reward, as is the added sense of accomplishment and valuable learning experience.

Thanks again for the excellent project post.