This is Part 2 of an article on Siri integration with a Home Automation system. Part 1 can be found here
The instructions are similar to those in part 1, but are specifically for installing SiriProxy on the Raspberry PI running Debian Wheezy. Follow this section if you’re installing on a Raspberry PI. Refer back to Part 1 for detailed errors and solutions, as well as customization of the proxy server. See Part 3 for integration with Home Automation Systems.
If you want to download a fully installed working version that just needs an IP address change, see the downloads section in Part 1
There’s nothing special about my configuration.
- iPhone 5 (6.0.2)
- Raspberry PI Model B (8GB Class 10 SD Card – Also had it working with 2GB Class 2)
An 8GB card is required. If there is sufficient (read: “overwhelming”) demand for a 4GB image I’ll make one.
Connect Raspberry to the network,Monitor/TV, and USB Keyboard (no mouse is required)
Do not apply power until the SD Card is inserted (see below). I power mine from a USB port on my PC while I’m working on it at my desk.
http://www.raspberrypi.org/downloads – 2012-12-16-wheezy-raspbian
Copy to SD Card (I use HDDRawCopy1.02Portable) – does not require any thing like “sys linux”, just insert and copy.
Double-click File and select the extracted .img
Select SD Card
Click Start and click OK to warnings
The copy took about 3 minutes on my PC
Install the SD in the Raspberry PI and power it up.
When you power on the Raspberry, the first thing you’ll see is raspi-config
Steps I carried out are as follows. (Step 1 is critical on the Wheezy image):
- ssh (enable)
- boot_behaviour (I turned off boot to desktop as I’ll do everything via command prompt and ssh
Upon completion you’ll be back in raspi-config
You MUST reboot at this point to expand the root filesystem; otherwise, you will run out of disk space installing Ruby.
The reboot will take a while, as it has to resize the filesystem
Once it’s back up, login as pi / raspberry again
At this point you should have an IP address if you’re using DHCP. (If not google “Wheezy Static IP”.) For the SiriProxy a DHCP reservation or Static IP should be used.
To find the ipaddress, run
We can now use ssh from our Mac/PC/ (I use TerraTerm)
Login: Username: pi Password: raspberry
Before we start, I’d recommend getting tmux, but feel free to skip. You’ll need this (or something similar), if you plan to start the SiriProxy server in the foreground (so you can see the output) and disconnect the terminal session (without backgrounding the server). This will let you disconnect, reconnect without the server stopping. This install process contains one very long step and I’d recommend running this with tmux in case you get disconnected. It also lets you run several terminal session with a single telnet/ssh login. (See Part 1 for more info)
sudo apt-get install tmux
I’m also going to create a user called “siri”
sudo adduser siri
Add to sudo group
sudo adduser siri sudo
Logout (Ctrl-D) and log back in as user siri
1. Install everything needed for Ruby, RVM, git, etc.
sudo apt-get install dnsmasq ruby build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
Select ‘y’ to continue.
2. Edit DNS
(You can skip this if your router or other DNS can handle it. See “DNS” below)
sudo nano /etc/dnsmasq.conf
Find the line starting with: #address=/double-click.net/127.0.0.1 (use Ctrl-W to search)
Add a new line redirecting the Apple’s Siri server to your local IP (from ifconfig)
Save and exit (Ctrl-O, Enter, Ctrl-X)
sudo /etc/init.d/dnsmasq restart
Test DNS is resolving correctly
Type Ctrl-C as soon as you see an ip address (almost immediately)
This should return Apple’s IP address (I got 220.127.116.11). Apple blocks ICMP, so the pings will timeout just make sure it resolves into a 17.x.y.z address.
3. Install RVM
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Don’t worry about the warning in red, the next two commands take care of it
Load RVM as a function and update profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
(I’d recommend using tmux for this bit)
rvm install 1.9.3
Don’t worry about this message:
No binary rubies available for: debian/wheezy_sid/armv6l/ruby-1.9.3-p374.
answer “Y” to all prompts (takes over an hour to run on the Raspberry)
If you get the following error, it’s likely that you ran out of disk space (run “df –k” to check).
Error running 'make', please read /home/pi/.rvm/log/ruby-1.9.3-p374/make.log There has been an error while running make. Halting the installation.
Set Ruby 1.9.3 as default
rvm use 1.9.3 --default
4. Install the SiriProxy
git clone git://github.com/plamoni/SiriProxy.git
Select ‘y’ to warning to continue.
cp ~/SiriProxy/config.example.yml ~/.siriproxy/config.yml
Takes a while too
5. Generate Certificates
6. Install the Certificate on your iPhone
You can use any mechanism to get it to the iphone. As I’m using TerraTerm, I just used SSH SCP (File menu -> SSH SCP…)
Another great alternative (if you’ll be doing a lot of editing on your local machine) is WinSCP:
E-mail the certificate yourself, click it and install on phone (ignore warning about it being untrusted)
Set a few things in the environment first and create a symbolic link so that rvmsudo works.
echo 'export rvmsudo_secure_path=1 ' >> ~/.bash_profile
sudo ln -s ~/.siriproxy /root/.siriproxy
rvmsudo siriproxy bundle
8. Start the server
rvmsudo siriproxy server
A message should appear saying something like:
Starting SiriProxy on 0.0.0.0:443.. SiriProxy up and running.
9. Set DNS server on phone
The last step is to point your iPhone at your DNS server. This will be the PI’s IP unless you are using an external DNS server.
- Got to Settings -> Wi-Fi
- Click the blue arrow next to your connection
- Enter the Linux VM’s IP
Try it anyway
Press and hold the home button.
Say the exact phrase “Test Siri Proxy”. It should respond with exactly “Siri Proxy is up and running” and you should see something like this:
Create server for iPhone connection start conn #, @zip_stream=#, @consumed_ace=false, @name="iPhone", @ssled=false> [Info - Plugin Manager] Plugins laoded: [#>] [Info - iPhone] Received Object: LoadAssistant [Info - iPhone] Received Object: SetRestrictions [Info - iPhone] Received Object: SetRestrictions [Info - iPhone] Received Object: ClearContext [Info - iPhone] Received Object: SetSessionObjects [Info - Guzzoni] Received Object: AssistantLoaded [Info - iPhone] Received Object: StartSpeechRequest [Info - iPhone] Received Object: SetRequestOrigin [Info - User Location] lat: XX.07408038900973, long: -YY.70323611215576 [Info - iPhone] Received Object: SpeechPacket [Info - Guzzoni] Received Object: SetConnectionHeader [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: FinishSpeech [Info - Guzzoni] Received Object: SpeechRecognized [Info - Plugin Manager] Processing 'Test Siri proxy ' [Info - Plugin Manager] Processing plugin # [Info - Plugin Manager] Matches (?i-mx:test siri proxy) [Info - Plugin Manager] Applicable states: [Info - Plugin Manager] Current state: [Info - Plugin Manager] Matches, executing block [Info - Plugin Manager] Say: Siri Proxy is up and running! [Info - Plugin Manager] Sending Request Completed
It’s extremely likely that the first time you test, you’ll get an error on the Linux host when you hold down the home button:
/home/siri/.rvm/gems/ruby-1.9.3-p374@SiriProxy/gems/CFPropertyList-2.2.0/lib/rbBinaryCFPropertyList.rb:217:in `encode': "\xDD" followed by "n" on UTF-8 (Encoding::InvalidByteSequenceError)
This seems to be due to CFPropertyList-2.2.0 being downloaded in place of CFPropertyList-2.1.2. I’ve seen various suggestions for a fix (google it). I know this is not the right way to do it, but it worked every time for me (and I’ve done it about 20 times). We’re basically downloading CFPropertyList-2.1.2 and copying its contents to the 2.2.0 directory (Make sure you use the correct home directory in the command below.)
gem install CFPropertyList -v 2.1.2
sudo cp -r ~/.rvm/gems/ruby-1.9.3-p374@SiriProxy/gems/CFPropertyList-2.1.2/* ~/.rvm/gems/ruby-1.9.3-p374@SiriProxy/gems/CFPropertyList-2.2.0
rvmsudo siriproxy bundle
rvmsudo siriproxy server
Now the Siri Proxy is up and running, further examples and Home Automation integration can be found in Part 3