Last Updated on May 1, 2023 by Freddy Reyes
After extensive online research and exploring various sources, I have summarized the process of controlling your SmartThings hub with Siri in this post. Here’s a guide on how to install Homebridge (an Apple HomeKit bridge) on a Raspberry Pi and integrate it with SmartThings:
1- You need to install your Raspberry Pi
- Install your Pi by following these instructions: https://www.raspberrypi.org/help/noobs-setup/
2- Install Node.js on the Raspberry Pi
sudo wget https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-armv7l.tar.gz
tar -xvf node-v16.17.0-linux-armv7l.tar.gz
cd node-v16.17.0-linux-armv7l
sudo cp -R * /usr/local/
To check Node.js is properly installed and that 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 and Homebridge Config UI X
Install Homebridge and Homebridge Config UI X using the following command:
sudo npm install -g --unsafe-perm homebridge homebridge-config-ui-x
Homebridge Config UI X is a web-based management tool for Homebridge that allows you to manage all aspects of your Homebridge setup.
To set up Homebridge as a service that will start on boot you can use the provided hb-service
command.
sudo hb-service install --user homebridge
5- Start Homebridge
- 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
6- Installing the Smartthings Homebridge plugin
Add the -I flag: homebridge -I
- Using Homebridge config UI install the Smartthings Homebridge plugin (from iklein99). This is a plugin to Homebridge to connect your Smartthings network to Apple Home Kit.
- You need to go to account.smartthings.com/tokens 370, sign in with your Samsung account and generate a token.
- Go to the Smartthings Homebridge settings and add your access token to the configuration.
- Note: If you want to display your devices (accessories), you will need to run Homebridge in insecure mode. The following lines show how to implement this feature.
Command Line:
Systemd
If you have configured Homebridge to start using systemd
by following the guide on the offical wiki then you can enable insecure mode by adding -I
to the HOMEBRIDGE_OPTS
variable in your
/etc/default/homebridge file.
Example:
# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
HOMEBRIDGE_OPTS=-U /var/lib/homebridge -I
# If you uncomment the following line, homebridge will log more
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*
Other Popular Plugins
These are other plugins popular plugins, 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
The modules will be installed in the following directory:
/usr/local/lib/node_modules
If you need to remove a module, you can run the following command:
sudo npm r homebridge-people
7- Add HomeKit to iOS
HomeKit is not an app; it’s a “database” similar to HealthKit and PassKit. If you upgraded your device to iOS 10 or above. In that case, 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 recommend changing 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, but iOS thinks otherwise. It can be fixed by deleting persist/ directory files next to your config.json. If the issue continues, the iOS device has gotten your Homebridge username (looks like a MAC address) “stuck” somehow, where it’s in the database but inactive. Fix: change yours username
in the “bridge” section of config.json
to be some new value.
8- Remote Access (outside the home network):
If you own a fourth-generation Apple TV or newer (or an iPad running iOS 10, HomePod). In that case, HomeKit accessories can be controlled with an iOS device away from home, even when Wi-Fi or Bluetooth is unavailable 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 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