SmartThings + Raspberry Pi & Homebridge = Siri HomeKit Controlled Smart Home

Here’s everything you need to get Siri controlling your Samsung SmartThings, Philips Hue lighting and Sonos using a Raspberry Pi running Homebridge. Automated Home reader (and media producer) Paul Gale takes us through his step-by-step guide finishing up with a rather impressive seasonal smart home video.

Hey Siri, make it Christmas!” Or how to get Siri to control HomeKit and non-HomeKit devices by using Samsung SmartThings and a Raspberry Pi to set a Christmas lighting scene on a range of bulbs and decorations and kick off the right playlist (UK specific instructions).

I’ve been automating my home for more than 15 years now with systems such as CBus lighting, wall mounted control panels, a Comfort alarm system, HomeVision hardware HA controller, whole-house audio, electric curtains and roof lights etc. The list was long. Oh, and around 8km of Cat5e cabling!

We recently decided to move and down-size a little but the result of that was that I had to say goodbye to most of my lovely automation kit. A result of so many years of research, installation and programming and chatting to the great guys on the Automated Home forums and mailing list. We’re now in a rented house, waiting for our new house to be built.

I just couldn’t resist the lure of Home Automation yet again as the default house lights were just sooo 1990’s and boring. Obviously I’m pretty restricted to what I can install in a rented property, so I invested in some wireless Philips Hue lamps, both the colour plug in type, some newer Iris wall washing colour lamps and a rather nice Hue beyond desk lamp. I’ve had the original Philips Hue Iris lamps for some years now but the newer versions link up together and with other lamps in the Hue system via a hub, all controllable via the Hue iOS app. Pretty cool eh?

Philips Hue Bulbs

Well, just recently, Philips updated the Hue hub to v2 and with this came Apple HomeKit support and the ability to control the lamps via spoken commands to Siri. Wow, that was fun and actually surprisingly useful, finding that we’d now control most of the Hue lights this way as it was just so much quicker than unlocking the iPhone, opening the app and stabbing at various buttons.

Then came the Samsung SmartThings system with its promise of easy integration and control of a number of very clever wireless sensors and devices. Naturally the SmartThings hub could also link to the Hue system and some other bits ‘n’ bobs I already had like a Logitech Harmony remote and a Sonos Play:1 speaker. I soon was wishing for Siri control of these new devices as unfortunately the SmartThings system isn’t natively HomeKit compatible. It turns out though that it is indeed possible via some very clever community projects and code.

SmartThings UK Starter Kit

The following guide was assembled to help others achieve HomeKit nirvana with a modest amount of kit and a few apps. I must stress that it’s mostly based on other people’s work and guides spread across many sites and pages but brought together into one hopefully useful guide. Huge credit to all those people in the various projects and forums for the amazing amount of work put in to enable others (for free) to achieve something special. Please do consider donating where there’s an option. I’ve also detailed the modifications needed to run this within the UK (and possibly Europe).

This does require a reasonable amount of effort and some knowledge of Windows, Linux and iOS but should be achievable for most average to advanced users.

No products found.

Hardware

Required:

You could run this on another Linux device instead, but you may have to modify the instructions slightly.

Optional:

Software

SmartThings - Make It Christmas

1. Install NOOBS & Raspbian on your Raspberry Pi

Install your Pi by following these instructions:

https://www.raspberrypi.org/help/noobs-setup/

When done, make sure you can log in to a terminal session on the RasPi, either by running Terminal in the RasPi GUI or by using a terminal app on Windows/Mac such as the excellent PuTTY.

You can log in and issue all of the commands shown here under the default ‘pi’ account on the RasPi. If connecting remotely via PuTTY, the default username is ‘pi’ and password ‘raspberry’ although in my install, the password wasn’t recognised so I had to change it from the Terminal app in the RasPi GUI using:

passwd

Then enter the new password twice as instructed. More info here:

https://www.raspberrypi.org/documentation/linux/usage/users.md

2. Install Node.js on the Raspberry Pi

There are now much later versions of Node.js than the instructions here:

http://blog.wia.io/installing-node-js-v4-0-0-on-a-raspberry-pi/

So this is what I did. Via a terminal window such as Putty on Windows:

This is for the Raspberry Pi 2 Model B – check the previous URL if you have an older version as the package is different.

wget https://nodejs.org/dist/v5.2.0/node-v5.2.0-linux-armv7l.tar.gz

tar -xvf node-v5.2.0-linux-armv7l.tar.gz

cd node-v5.2.0-linux-armv7l

sudo cp -R * /usr/local/

To check Node.js is properly install and you have the right version, run the command:

node –v

You might also want to check that NPM is the latest version as on my RasPi it was quite old and I ran into some problems trying to install HomeBridge. This will install/upgrade to the latest version:

sudo npm install npm -g

3. Install Homebridge on the Pi

https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi

sudo npm install -g homebridge

sudo npm install -g homebridge-legacy-plugins

Now we need to make some changes to the smartthings.js file for the UK/EU servers:

cd /usr/local/lib/node_modules/homebridge-legacy-plugins/platforms

nano SmartThings.js

Find the following URL in the file:

https://graph.api.smartthings.com

and replace it with:

https://graph-eu01-euwest1.api.smartthings.com

In my version of the file, there was only one instance of this. Ctrl-O and Enter to save the file, then Ctrl-X. This setup isn’t quite complete yet, you’ll need to complete the following before Homebridge will run.

4. Install the SmartThings app on your iPhone

You should already have the SmartThings app on your phone. If not, install and set it up now by following the instructions that came with the SmartThings kit (or hub)

5. Login to the SmartThings IDE and create a JSON API SmartApp

https://graph-eu01-euwest1.api.smartthings.com/

The SmartThings IDE (Integrated Development Environment) provides a set of tools to manage a SmartThings account and hubs, devices etc. It’s actually quite useful for a number of reasons but we’ll be using it here to install a custom JSON API SmartApp that’s a key part of the process in getting Siri to control our non-HomeKit devices.

Login using your SmartThings account that you created as part of the SmartThings kit/hub install.

Goto the ‘My SmartApps’ tab

Click ‘+ New SmartApp’ button top right

Click ‘From Code’

In another browser window, go here:

https://github.com/jnewland/SmartThings/blob/master/JSON.groovy

click the ‘Raw’ button

Select all the code (Ctrl-A) and copy it (Ctrl-C)

Go back to the SmartThings IDE window and paste the code you just copied into the code window.

Find all instances of

https://graph.api.smartthings.com

and replace them with

https://graph-eu01-euwest1.api.smartthings.com

There should be three instances on lines 59, 63 and 87 – this is correct at time of writing (11/12/15). Of course this code may change in the future. If you have a US account, you don’t need to do this as the server URL will be correct for you.

Click ‘Create’

Click ‘App Settings’

Click ‘OAuth’

Click ‘Enable OAuth in Smart App’ leave all settings as defaults

Click ‘Update’

The SmartThings IDE seems to lose the menu buttons at this point, so you may need to click the ‘My SmartApps’ tab again, click the ‘ jnewland : JSON API’ entry to get back to a point where you can now:

Click ‘Publish’ and ‘For Me’

6. Install the new JSON API SmartApp in SmartThings

Load the SmartThings app on your iPhone.

Go to the ‘Marketplace’ by tapping the icon in the bottom right (blue, green and yellow icon that looks a bit like a star).

Tap ‘My Apps’

Tap ‘JSON API’

You can now select any of the switches and Philips Hue lamps that you want to control via Homebridge/HomeKit/Siri (note that Philips Hue v2 hub now supports HomeKit natively so you may not want to select Hue devices here as they may already be in the HomeKit database and controllable). You can come back to this screen in the future and change your selections, so you may just want to try a single device for testing. If you do later change these devices, you may need to stop and restart the Homebridge server for the new or changed devices to be discovered and entered into the HomeKit database.

Tap ‘Config’

The next screen should then display the configuration that we need to use in the Homebridge server. It should look something like this (I’ve replaced the actual keys with xxx):

{
    "description": "JSON API",
    "platforms": [
        {
            "platform": "SmartThings",
            "name": "SmartThings",
            "app_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "access_token": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        }
    ]
}

Copy this or send it via email, PushBullet or whatever other method you might have for sending text from an iPhone to your desktop machine. I use the PushBullet app and Firefox plugin which works quite well. Unfortunately, this step is a little cumbersome as SmartThings don’t have an app for anything but a mobile device (not even an iPad version I believe).

Tap ‘Done’ and ‘Done’ again to exit the SmartApp. SmartThings should display a banner saying that “JSON API is now installed and automating”

7. Setup a config.json file for Homebridge

We’ll now use the configuration text from the previous step and create a config.json file for the Homebridge server.

Back in your terminal window connected to your Raspberry Pi:

cd /home/pi/.homebridge

nano config.json

Now paste in the configuration text. If you’re using PuTTY, you can copy the configuration text and right click on the PuTTY window to paste it in.

Ctrl-O to write the file. Make sure the filename is ‘config.json’ and press enter. Ctrl-X to exit the nano editor.

Check the file now exists:

ls

You should see ‘config.json’ listed.

Now we can start the Homebridge server:

Homebridge

If all is successful, you should see something like this output (the warning messages don’t seem to affect operation of the server):

pi@raspHA:~/.homebridge $ homebridge
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
Loaded plugin: homebridge-legacy-plugins
Registering accessory 'homebridge-legacy-plugins.AD2USB'
Registering accessory 'homebridge-legacy-plugins.Carwings'
.
(some output replaced for brevity)
.
Registering platform 'homebridge-legacy-plugins.LIFx'
Registering platform 'homebridge-legacy-plugins.MiLight'
Registering platform 'homebridge-legacy-plugins.Openhab'
Registering platform 'homebridge-legacy-plugins.SmartThings'
Registering platform 'homebridge-legacy-plugins.TelldusLive'
Registering platform 'homebridge-legacy-plugins.Wink'
Registering platform 'homebridge-legacy-plugins.YamahaAVR'
Registering platform 'homebridge-legacy-plugins.ZWayServer'
---
Loaded config.json with 0 accessories and 1 platforms.
---
Loading 1 platforms...
[SmartThings] Initializing SmartThings platform...
Loading legacy platform SmartThings
[SmartThings] Fetching SmartThings devices...
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐
│ undefined               │
└────────────┘

Homebridge is running on port 51826.

If you want to run the Homebridge server at start-up, you can follow the instructions at the bottom of the page here:

https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi

8. Install “Elgato Eve” app on your iPhone

Apple App Store LogoInstall “Elgato Eve” from the app store, it’s free. This app enables you to view all of the Homekit devices and arrange them into rooms, scenes and other collections. It’s this arrangement (the Homekit database) that Siri uses to find devices to control. Other similar apps are available but I prefer this one and as I mentioned, it’s free 

In ‘Settings’ you should now select ‘Add accessory to xxxxx’s Home’. The Homebridge accessory should show up – select it and follow the instructions to add it to Apple HomeKit. If prompted for a ‘PIN Code’, the default code is:

031-45-154

In the Eve settings you can now add all of the rooms you have devices in. This isn’t strictly necessary but does mean that Siri can find devices based on room names too. Very cool!

If you tap the ‘At a glance’ button, you should now see the devices you selected in the JSON SmartApp API in SmartThings. You can also control them from here. You’ll also see any other HomeKit enabled devices in the Eve app as it’s a window into the Apple HomeKit database.

All of your devices will probably be assigned to the Home (Default Room) room – you can tap ‘Edit’ and select the cog settings icon for each one and place them in the room of your choice. Then just tap ‘Back’ and it’s saved. I did run into what appears to be a bug or issue in the Eve app trying to create a new room ‘Dining Room’. For some reason it just wouldn’t add the new room. Odd.

So you now should be able to control your lights and devices from Siri. Again, the excellent Homebridge page below talks a bit more about this:

https://github.com/nfarina/homebridge

“Hey Siri, make it Christmas!”

So now when I give the command above, the following happens:

  • Philips hue bulbs in the table lamps turn on at 80% and a nice purple hue
  • A floor lamp connected via a SmartThings plug socket turns on
  • Two Philips Hue Iris lamps turn on at 100%, casting a purple light up the walls
  • The Christmas tree lights turn on, along with a collection of other Christmas decorations
  • The Lounge Sonos speaker starts playing Christmas tunes!

This can easily be achieved by creating a scene in the Eve app. It can also be done numerous other ways by using SmartThings and getting HomeKit (via the Eve setup) to trigger a virtual device in SmartThings maybe. The possibilities are endless.

How cool is that!

No products found.

[Comments closed for this post – please discuss in our SmartThings Forums instead]

Last update on 2024-03-15 / Affiliate links / Images from Amazon Product Advertising API