Voice Controlled Garage Door

As seen previously (more), I’ve got our garage door hooked up to the internet. Now that we’ve both got Siri though, it seemed like I ought to be able to ask her to open the thing. Apple doesn’t yet provide any kind of API into or out of Siri, but you can get her to send texts.

Which brings us to Twilio, a fantastically easy to use SMS and voice menu API. It’s about as simple as I can imagine it being to set up a number on Twilio that, when texted, forwards the text along to a web URL of your choosing. So all I needed to write was a tiny web app to bridge SMS messages from Twilio to Indigo‘s web interface.

Since I’ve been working on Buzz, a tiny little web framework written in Lua, I decided to use that for my bridge.

So given all the various pieces were already in place, this is all the new code I had to write for this entire project. As a bonus, I can turn the lamp behind me in my office on and off too (mostly because it was a lot more comfortable sitting at my desk writing this than sitting on the garage floor!)

With this app running and Twilio set up to send texts to it, I made a contact on my phone named “House” with my new Twilio number, and can now tell Siri “Text house open the garage”, and the door will open. Technically it will open or close, it’s just a toggle, but you can see how to modify this code to do more stuff, or be smarter about it, pretty easily. Until Apple opens up the Siri API, this is a pretty good poor man’s substitute.

local ffi=require('ffi')
ffi.cdef [[
	int	system(const char *command);
function homecontrol(request)
  request.headers['Content-Type'] = 'text/xml'
  body = body:lower()
  if body:find('lamp') then
	ffi.C.system('curl -X PUT -d toggle=1 http://sideshowbob.local:8176/devices/OfficeLamp')
	response='Turned the office lamp on or off'
  elseif body:find('garage') then
	ffi.C.system('curl -X PUT -d outputBinaryStates="1,0,0,0,0,0,0,0" http://sideshowbob.local:8176/devices/GarageDoor')
	response='Activated the garage door'
				'<?xml version="1.0" encoding="UTF-8"?>\n'..
buzz.get('^/homecontrol/\?.*$', homecontrol)

Some issues with the above code:

  • There’s no security at all, other than the phone number being a secret. Anyone could open the garage if they knew the right number to send a text to, or the right URL to send a Twilio-like request to. There are several really simple things that could be done to greatly increase security, if one were worried about it.
  • It should really be set up as a PUT or POST request, as something is OBVIOUSLY changing state as a result of the request! But Buzz only does GET requests right now. Luckily Twilio can deal with that.
  • It requires luajit, rather than working with plain old lua, since I’m using ffi to make a system() call to curl. There are better ways to do that, but ffi makes things like that really easy for experienced C programmers. Buzz itself requires luajit for the socket layer anyway, though I don’t think it will forever.


  1. Mice Control And Extermination Said,

    August 21, 2013 @ 4:40 pm

    Hi there to all, it’s in fact a good for me to go to see this site, it consists of useful Information.

    My weblog; Mice Control And Extermination

  2. Dorinda Randleman Said,

    February 9, 2014 @ 6:14 pm

    Great information, better still to find out your blog that has a great layout. Nicely done.

  3. www.spaskin.com Said,

    March 4, 2014 @ 12:13 pm

    It is a challenging situation for sellers as they have to fulfill the demands and conditions
    set by the consumer and distributorsin order
    to survive in the market. Although cosmetic companies argue that their products contain
    a tiny amount of these ingredients the cumulative effect of using these products over
    time has not been tested. Supporters of cosmetic animal testing, claim it is
    simply good business practices.

  4. spaskin.com Said,

    March 18, 2014 @ 10:40 am

    This can be obviously simply rectified by taking inside the important
    vitamins. If you don’t like to eat first thing in the morning,
    then drinking a protein shake or a fruit
    smoo. At this stage, it is a good idea to get in touch
    with a medical professional who will offer the best acne treatment available based on your skin type and severity of your acne condition.

  5. Russell Organics Maracuja Oil Said,

    May 25, 2016 @ 2:10 pm

    This oil is a real multitasker, as it is beneficial for both dry and oily
    complexions, and of course normal or sensitive skin types.
    Of all the ingredients used in skin care today, maracuja
    oil is one of the best when it comes to making your skin smooth and soft.
    The benefits of avocado oil for skin are plenty: first
    of all it is packed with vitamins A, D and E, lecithin, beta-carotene, potassium, antioxidants and
    essential proteins that all benefit your skin and help you keep looking younger for longer.

  6. Legal Aid Society Of Cleveland Said,

    June 17, 2018 @ 8:16 am

    Valuable info. Fortunate me I discovered your website by chance, and I’m surprised why this twist of fate didn’t happened earlier! I bookmarked it.

  7. Technology Innovative Apps Said,

    December 28, 2018 @ 10:05 am

    Very well written article. It will be supportive to everyone who usess it, as well as myself. Keep up the good work – looking forward to more posts.

  8. Josephine Said,

    January 12, 2019 @ 2:56 pm

    It is truly a nice and useful piece of information. I am satisfied that
    you just shared this helpful info with us. Please
    stay us up to date like this. Thank you for sharing.

  9. jasa fumigasi Said,

    April 15, 2019 @ 2:48 am

    I am typically to blogging and i actually admire your content. The article has really peaks my interest. I’m going to bookmark your site and maintain checking for new information.

RSS feed for comments on this post · TrackBack URI

Leave a Comment