Page 1 of 9

Siri: Open my garage door..

Posted: Sun Dec 09, 2012 12:06 pm
by DarkTherapy
Hi, this is my first real Raspberry Pi project - SiriProxy running on the Raspberry Pi, along with wiringPi to access the Pi's GPIO pins and turn a relay on/off. The relay is then hooked up to my automatic garage door system. So, I have control of the door with Siri on my iPhone.

There are probably other ways to do the same thing, such as running a web server on the Pi and have that access the GPIO's etc but I basically cobbled this together for my own needs - and it works fine.

I am running the Pi as "root" for this whole setup as it just makes things easier for me and I'm using the "wheezy" distro.
Follwing the instructions here: http://www.idownloadblog.com/2011/12/09 ... ial-video/ should get SiriProxy up and running, if you do follow these instructions then swap commands 11, 12 and 13 to 12, 13, 11. Command 7 by the way will take about 90 minutes to compile on the pi!

Then install wiringPi from https://projects.drogon.net/raspberry-p ... d-install/

Once these are installed its just a case of modifying the example ruby script included with siriproxy.
Edit this file: /root/SiriProxy/plugins/siriproxy-example/lib/siriproxy-example.rb

Look for the lines:

Code: Select all

  listen_for /test siri proxy/i do
    say "Siriproxy is up and running!" #say something to the user!

    request_completed #always complete your request! Otherwise the phone will "spin" at the user!
  end
And add this directly under them:

Code: Select all

  listen_for /open the garage door/i do
    say "Opening the garage door.."
    request_completed
    system("gpio mode 1 out")
    system("gpio write 1 1")
    system("sleep 0.5")
    system("gpio write 1 0")
  end

  listen_for /close the garage door/i do
    say "Closing the garage door.."
    request_completed
    system("gpio mode 1 out")
    system("gpio write 1 1")
    system("sleep 0.5")
    system("gpio write 1 0")
  end
As you can see, the ruby script is basically calling "system" commands to access wiringPi. Setting a GPIO pin as an output then setting it high for half a second then low again.

You can have siri to call any command you can type in a terminal window, such as a passwordless SSH login to a remote pc to have it shut down or rebooted.

Code: Select all

  listen_for /turn off my laptop/i do
    response = ask "Are you sure you want me to shut down your laptop?"

    if(response =~ /yes/i)
      say "OK, I'll shut it down now.."
      system("ssh [email protected] shutdown -h now")
    else
      say "OK, I wont!"
    end

    request_completed
  end
You could have RasPI's in different rooms with different commands to follow, all from one siriproxy server. Note: each time you modify the example plugin you must run the "siriproxy bundle" command before restarting the server.

Anyway, here is a video of my setup.

http://youtu.be/NUJ5z76Xv5o

Re: Siri: Open my garage door..

Posted: Sun Dec 09, 2012 5:09 pm
by liz
Coming to a front page near you very soon! Than you very much for posting this - lovely bit of work.

Re: Siri: Open my garage door..

Posted: Sun Dec 09, 2012 5:29 pm
by DarkTherapy
liz wrote:Coming to a front page near you very soon! Than you very much for posting this - lovely bit of work.
Thank you for the positive feedback Liz.

Re: Siri: Open my garage door..

Posted: Sun Dec 09, 2012 5:51 pm
by Paul Webster
Next challenge - "Siri, make space in the garage for my car"

Re: Siri: Open my garage door..

Posted: Sun Dec 09, 2012 5:54 pm
by DarkTherapy
Paul Webster wrote:Next challenge - "Siri, make space in the garage for my car"
More importantly, "Siri: get me driving lessons, and a car to replace my bicycle"

:0)

Re: Siri: Open my garage door..

Posted: Sun Dec 09, 2012 9:34 pm
by texy
Nice project. I've got a garage door......but no garage ;)
However, it'd be pretty cool to be able to control other things via siri.
Currently compiling ruby..............

One thing i,d didn't do though is add the -k curl additional option - what effect will this have?
Texy

Re: Siri: Open my garage door..

Posted: Mon Dec 10, 2012 2:20 am
by Schorschi
I got a big laugh out this idea! What a great idea. I am kind of disappointed I did not think doing it... yet. I have been focusing on doing stuff with XBMC on Pi, other than setting up one Pi device to act as my DNS/NTP/DHCP, etc. local network services, always on resource, since running a full Linux box for same is over kill, and I have never been happy with the limited services (even using DD-WRT, which is actually pretty good in its own right) on my internet rounter. I like this idea so much, I have it on the list to do it. I also want to setup a PBX, control my garden lighting, my pool system, garden sprinklers, and more over time. Some day I may even get around to doing the LED cube project (check out Youtube for the LED cube video), especially if I could weatherize it... what great idea for Christmas lighting, no?

Re: Siri: Open my garage door..

Posted: Mon Dec 10, 2012 6:33 am
by DarkTherapy
This would be great for Christmas lights, I'll probably buy another RasPi in the new year and make a multiple relay switch box - the siriproxy pi will talk to this second pi. I forgot to add that I use SiriProxy within a "screen" session so I can SSH into the pi to start the server and it continues to run when I log out.

Re: Siri: Open my garage door..

Posted: Mon Dec 10, 2012 7:32 am
by rurwin

Code: Select all

listen_for /open the garage door/i do
    say "I'm sorry Dave, I'm afraid I can't do that."
    request_completed
end

 listen_for /please open the garage door/i do
    say "Opening the garage door.."
    request_completed
    system("gpio mode 1 out")
    system("gpio write 1 1")
    system("sleep 0.5")
    system("gpio write 1 0")
  end

Re: Siri: Open my garage door..

Posted: Mon Dec 10, 2012 8:13 am
by DarkTherapy
rurwin wrote:

Code: Select all

listen_for /open the garage door/i do
    say "I'm sorry Dave, I'm afraid I can't do that."
    request_completed
end

 listen_for /please open the garage door/i do
    say "Opening the garage door.."
    request_completed
    system("gpio mode 1 out")
    system("gpio write 1 1")
    system("sleep 0.5")
    system("gpio write 1 0")
  end
LOL

Re: Siri: Open my garage door..

Posted: Mon Dec 10, 2012 8:51 pm
by texy
Siriproxy is up and running!

Now to make it do something useful !!

Texy

Re: Siri: Open my garage door..

Posted: Mon Dec 10, 2012 9:07 pm
by DarkTherapy
texy wrote:Siriproxy is up and running!

Now to make it do something useful !!

Texy
That's the fun part ;0)

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 4:50 pm
by Montekuri
Paul Webster wrote:Next challenge - "Siri, make space in the garage for my car"
Siri: I'm sorry, Dave. I'm afraid I can't do that.

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 6:24 pm
by aframe
That's amazing!

Gonna have to get this integrated into my stuff for sure!

How does the author manage to get it to return numbers/strings like the thermostat temperature dynamically though? Any idea?

I have some output coming from a python script that I'd like to feed back to the user.

End of hijack - great post!!!

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 6:31 pm
by DarkTherapy
I'm not to sure to be honest, I guess it's possible in ruby/python.. I just knocked this together for the fun of it, didnt think it would be that popular!

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 6:36 pm
by aframe
DarkTherapy wrote:didnt think it would be that popular!
FAIL!! :)

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 8:27 pm
by texy
Turing a green LED on and off : no problem.
But siri doesn't understand me when I say 'red on' - keeps thinking I,m saying 'read', not red :roll:

Texy

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 8:45 pm
by DarkTherapy
Try "turn the other LED on.." lol

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 9:04 pm
by texy
One assumes that when you are on your drive, your iphone is within wifi range. Pushing the boat out here, but how can this be used over t'net,
ie if the iphone is not on the same local network?

Texy

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 9:20 pm
by DarkTherapy
It's possible to setup a VPN that connects your phone to your home network, I'm not sure if the pi can handle that at the same time as running the Siri proxy.

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 9:27 pm
by texy
...make that your next project ;)
Thanks again for showing us all this fun pi project.
Texy

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 10:38 pm
by DarkTherapy
All credit should go to Pete - https://github.com/plamoni/SiriProxy

He created SiriProxy, I simply modified some of the code for my own use :0)

Re: Siri: Open my garage door..

Posted: Tue Dec 11, 2012 11:21 pm
by joshftx
Great work. There's an alternative to Siri proxy called Siri server core that i played with some time ago. Its written in Python and works like a charm with lots of great plugins. I thought about doing a project similar to this myself but never got around to it. https://github.com/Eichhoernchen/SiriServerCore

Re: Siri: Open my garage door..

Posted: Wed Dec 12, 2012 6:29 am
by bJacoG
This might be a dumb question, but a bit of googling got me nowhere.

Is there an android alternative to siriProxy? That works with the android voice actions perhaps?

Re: Siri: Open my garage door..

Posted: Wed Dec 12, 2012 9:45 am
by Levaillant
Just AWESOME! Nice job