magnify
Home Apple How to Control your Smartthings Hub with Siri using a Raspberry Pi
formats

How to Control your Smartthings Hub with Siri using a Raspberry Pi

AppleSiri1TNW-1200x651After researching many hours on the internet and reviewed several sites related to the topic, I decided to summarize the details on how to control your smartthings hub with Siri and put together this post.

Here is how to install Homebridge (Apple HomeKit bridge) on a Raspberry Pi and integrate it with Smartthings:

1- You need to install your Raspberry Pi

2- Install Node.js on the Raspberry Pi

  • 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

3- Install the latest version of NPM

  • sudo npm install npm -g

4- Install Homebridge on the Homebridge

5- Login to the SmartThings IDE (https://graph.api.smartthings.com) and create a JSON API SmartApp

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.

  • Click ‘Create’
  • Click ‘App Settings’
  • Click ‘OAuth’
  • Click ‘Enable OAuth in Smart App’ leave all settings as defaults
  • Click ‘Update’
  • 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 devices that you may want to control with HomeKit.

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”
}
]
}

Tap ‘Done’

7- Setup a config.json file for Homebridge

  • Connect to your Raspberry Pi:
  • cd /home/pi/.homebridge
  • sudo vi config.json

Sample File:

{
“bridge”: {
“name”: “Homebridge”,
“username”: “XX:XX:XX:XX:XX:XX”,
“port”: 51826,
“pin”: “XXX-XX-XXX”
},
“description”: “JSON API”,
“platforms”: [
{
“platform”: “SmartThings”,
“name”: “SmartThings”,
“app_url”: “https://graph.api.smartthings.com:443/api/smartapps/installations/”,
“app_id”: “xxxxxxxxxxxxxxxxxxxxxxxx”,
“access_token”: “xxxxxxxxxxxxxxxxxxxxxxxxx”
}]
}

  • Now we can start the Homebridge server by running: homebridge
  • To view the running logs, you can tail the output log or error log:
    • tail -f /var/log/homebridge.log
    • tail -f /var/log/homebridge.err

8- Install plugins (https://www.npmjs.com/search?q=homebridge-plugin)

These are the ones that I tried and it’s respective npm commands:

  • sudo npm i homebridge-harmonyhub
  • sudo npm i homebridge-people
  • sudo npm i homebridge-platform-wemo
  • sudo npm i homebridge-lifx-lan
  • sudo npm i homebridge-thermostat

9- Add HomeKit to iOS

17278-14617-ios10-homeapp-l

HomeKit is actually not an app; it’s a “database” similar to HealthKit and PassKit. If you upgraded your device to iOS 10, there is a new app called “Home” where you should be able to discover the “homebridge” device on your network (if you have an older iOS version you can also try iDevice, Eve or Devices to discover “homebridge”).

When you attempt to add Homebridge, it will ask for a “PIN code”. The default code is 031-45-154, but I highly recommend you to change it to something else.

If iOS can’t find Homebridge, it could be related to the fact that the Homebridge server thinks it’s been paired with, but iOS thinks otherwise. It can be fixed by deleting persist/ directory files which are next to your config.json. If the issue continues, iOS device has gotten your Homebridge username (looks like a MAC address) “stuck” somehow, where it’s in the database but inactive. Fix: change your username in the “bridge” section of config.json to be some new value.

10- Remote Access (outside the home network):

If you own a third-generation Apple TV or newer (or an iPad running iOS 10), HomeKit accessories can be controlled with an iOS device away from home, even when Wi-Fi or Bluetooth are not available and you’re using a phone’s cellular connection.

Instructions:

  • Disable 2-factor authentication
  • On Apple TV, sign out of iCloud and iTunes Store
  • Sign back on on both iCloud and iTunes Store
  • Verify that you can access Homekit from outside the home network (turn off wifi on your iphone)
  • Re-enable 2-factor authentication

Note:

For additional information please check: https://github.com/nfarina/homebridge/wiki/Running-HomeBridge-on-a-Raspberry-Pi

Comments

comments

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
Comments Off on How to Control your Smartthings Hub with Siri using a Raspberry Pi  comments