We have moved at community.getvera.com

Author Topic: "SiriProxy is up and running!" - ON my Vera3  (Read 9336 times)

Offline whyter

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
"SiriProxy is up and running!" - ON my Vera3
« on: January 19, 2012, 08:25:34 pm »
Whew - what an exercise in patience.. I got Ruby, SiriProxy, and all the associated libraries installed and running on the Vera - and as a bonus it actually works! It is a serious hack-job at the moment, with gems mixed with other libraries, no proper library paths set up for Ruby, things pretty much all over the place, but it works.

I had to hack quite a few things to get it to compile under the openwrt buildroot, and I know the shared libraries are currently bloated, but here's the low down on space used:

root@MiOS_30001573:~# du -sh SiriProxy/
71.0K   SiriProxy/

AND the big one

root@MiOS_30001573:/usr/lib# du -sh ruby/
9.6M   ruby/

I will say this.. With debug level turned up and spitting out data to the screen, it is noticeably slower than running on my virtual machine, as expected. But it is fast enough to process my requests and turn stuff on and off.

I will work on cleaning this up, and make it available for anyone that wants it.. Although I imagine that this pretty much voids any sort of warranty on the device??

Questions? Comments?

Thanks,
Rob

Offline Richard

  • Sr. Newbie
  • *
  • Posts: 34
  • Karma: +0/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #1 on: January 19, 2012, 09:26:44 pm »
Nice work.  :)

Offline autotoronto

  • Full Member
  • ***
  • Posts: 190
  • Karma: +0/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #2 on: January 19, 2012, 10:21:15 pm »
That's awesome!

I'm just curious - why is Ruby a sensible choice? I know the original code was written in Ruby and there's no reason why anyone should rewrite it but is its structure particularly appropriate for this task such that it was chosen in the first place?

Offline whyter

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #3 on: January 20, 2012, 09:20:05 am »
I'm not sure why the original author chose Ruby - but I can make some assumptions after spending so much time getting it working on this platform. It uses a few libraries that are very well suited for how SiriProxy works.

iPhone sends a header as follows:
[Header - iPhone] ACE /ace HTTP/1.0
[Header - iPhone] Host: guzzoni.apple.com
[Header - iPhone] User-Agent: Assistant(iPhone/iPhone4,1; iPhone OS/5.0.1/9A405) Ace/1.0
[Header - iPhone] Content-Length: 2000000000

Couple things to note there that make this awkward for a standard HTTP server.
1) The HTTP method (or verb) is 'ACE' - This is not the standard 'GET', 'POST, 'HEAD' ...
2) The Content-Length is always set to 2000000000


These 2 pieces could be hacked into lighttpd, and I did in fact add an 'ACE' method to lighttpd and get it up and running. What I didn't do was add a new method handler and chose to try to use the 'POST' handler, which proved to be impossible because 'POST' handler relies on the content-length to know how much data to read. (In typing this response just now I realize that I should have tried to use the 'GET' handler, because 'GET' will look for a blank line \r\n, and ignore content-length - although the W3C standards say something about ... 'GET' "SHOULD NOT have the significance of taking an action other than retrieval"... But since it was a hack only, that probably would have worked.

So next SiriProxy establishes a SSL connection to guzzoni.apple.com and forwards on the packet it received from the iPhone
Retrieves a response - and this is where the "magic" happens

Unzip the data
Process the header to find out where the binary packed plist is
Unpack the binary data into a CFPropertyList class that can easily be managed and find data in
Locate the "Text =" strings to determine what the user spoke into the iPhone
Look up the text locally to see if it matches something we want to act on - if not return the packet from apple to iPhone
Create the response text, send it back to the iPhone
And finally execute any external commands

The parts in RED are what are easily done with existing Ruby libraries. I ported CFPropertyList to Lua, but only got thru unpacking the data, didn't finish re-packing to send responses. I stopped because I felt like if I was going to be doing that much hacking anyway, I might as well just get Ruby running on the device and be done with it.

Hope that long winded answer made some sense.

Rob

Offline autotoronto

  • Full Member
  • ***
  • Posts: 190
  • Karma: +0/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #4 on: January 20, 2012, 10:12:38 am »
It does, very much - thanks.

Which is the slow part?

Offline whyter

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #5 on: January 20, 2012, 11:22:32 am »
The slow part turns out to only be with debug level turned up > 5 .. I guess it's all the print statements and outputting the debug info. With debug level == 1, it appears to me to run as fast on the Vera as on my virtual Ubuntu install.

Rob

Offline autotoronto

  • Full Member
  • ***
  • Posts: 190
  • Karma: +0/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #6 on: January 20, 2012, 02:04:06 pm »
What are you thoughts on integrating it with the Vera UI, scenes, etc?
I wonder if you could parse the Vera userdata file in Ruby - that would give you instant access to scenes and device names.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
« Last Edit: January 22, 2012, 11:33:07 am by Ap15e »

Offline autotoronto

  • Full Member
  • ***
  • Posts: 190
  • Karma: +0/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #8 on: January 22, 2012, 11:13:23 am »
True, reading the file is a lousy idea.

There are so many interfaces into Vera that there's no need to couple to luup at all; use one of the remote connection mechanisms like iVera uses (http://wiki.micasaverde.com/index.php/UI_Notes) to make a Siriproxy "remote interface" to Vera in Ruby. That means that you have the choice of running it either remotely or on the Vera hardware. For instance a raspberryPi unit would make a great SiriProxy server.

BTW your Remote Invocation link isn't available to mortals.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #9 on: January 22, 2012, 11:35:52 am »
Link added for mortals. Thanks for spotting this.

Offline woodsby

  • Beta Testers
  • Sr. Member
  • *****
  • Posts: 466
  • Karma: +1/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #10 on: March 08, 2012, 05:39:09 am »
So, I've been playing around with this quite a bit (how cool is it when regex matching meets voice control), and I'm wondering a few things:

1) Is anyone working on a siriproxy plugin for this?

2) I noticed a few parallel threads on the forum about this (although I haven't seen any new activity in the last month - maybe I missed something) - do we want to consolidate efforts into one thread

3) Has anyone upgraded to IOS5.1?  Part of me thinks that projects like siri proxy are helping apple sell iphones, but the rest of me realizes apple doesn't like other kids breaking into their playground... I'm wondering if IOS5.1 has done anything to our ability to use siri proxy before I upgrade.
Vera1 (1.1142), Vera2 (1.1182), VRI06 (12), VRS15 (3), VRS05 (2), VRF01 (2), VRCS4 (2), ZRW113, ZRF113 (2), 45602, 45603, TZMT400 (2), FE599 (2), 99100, Thinkstick, Harmony 890Pro (2), Harmony RF Extender, Nevo S70, Nevo NC-50, Minimote, SQ Remote, SQ Blaster, EtherRain-8, Cliste ActiveRFID, TED5002

Offline rlmalisz

  • Sr. Member
  • ****
  • Posts: 400
  • Karma: +1/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #11 on: March 08, 2012, 10:26:02 am »

3) Has anyone upgraded to IOS5.1?  Part of me thinks that projects like siri proxy are helping apple sell iphones, but the rest of me realizes apple doesn't like other kids breaking into their playground... I'm wondering if IOS5.1 has done anything to our ability to use siri proxy before I upgrade.

I just nudged my 4S into updating.  SiriProxy works for me just as it did before.

--Richard

Offline djrobx

  • Jr. Member
  • **
  • Posts: 94
  • Karma: +1/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #12 on: March 11, 2012, 07:43:18 pm »
I got SiriProxy up on 5.1 as well.  (running on a server, not Vera).    Plan to add some http get requests to talk to Vera.  That part is pretty easy and I'm doing that with my alarm system now.   It will be killer to just say "turn on the family room ceiling fan" or "Set the thermostat to 74 degrees" or "Heat up the spa."

Very exciting stuff, but I'm guessing SiriProxy's days will be numbered, especially as iOS gets updated.   All Apple needs to do is lock Siri to Apple's certificate (currently it accepts the generated cert).   By that time hopefully Apple will offer some sort of official extendability to Siri for iOS applications.

Until then, I can not update my phone and hopefully enjoy it for a long time though.  :)

Offline parkerc

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2479
  • Karma: +35/-48
  • Life Moves Pretty Fast....
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #13 on: July 27, 2012, 06:18:44 pm »
Hi, I was just wondering how people were progressing with Siri and Vera?
Is it a match made in silicon heaven?

Offline juamonco

  • Newbie
  • *
  • Posts: 17
  • Karma: +0/-0
Re: "SiriProxy is up and running!" - ON my Vera3
« Reply #14 on: September 20, 2012, 03:00:45 am »
Hi, now that iOS 6 is oficially released, do you know if Siriproxy stills works? I've seen here there is some progress about it. https://github.com/jimmykane/The-Three-Little-Pigs-Siri-Proxy/issues/302

One other question, Could you post your plugin in the plugins page of the siri proxy github? https://github.com/jimmykane/The-Three-Little-Pigs-Siri-Proxy/wiki/Plugins

Many thanks.

Juan