Setting up HomeBridge
C_LOG_13
December 12, 2015This week I read about homebridge. This immediately peaked my interest in my adventures with the Raspberry Pi. I wonder if I could ask siri to flash the led? I suppose the easiest way is to see if we can get homebridge setup based on the readme.md.
sudo npm install -g homebridge
After a few seconds I ran the command homebridge
and just as the guide said I received an error about setting up the config file.
Marks-iMac:HomeBridge markcoleman$ homebridge
No plugins found. See the README for information on installing plugins.
Couldn't find a config.json file at '/Users/xxxxxxx/.homebridge/config.json'. Look at config-sample.json for examples of how to format your config.js and add your home accessories.
Next I navigated to the directory in the error message and ran touch config.json
to create the file and then nano config.json
. Now what should this config file look like? In the root of the repo there is a sample config file.
Running the command homebridge
again resulted in an error which I sort of expected since I didn't install any plugins. Let's back track a bit and install the sample lock first.
sudo npm install -g homebridge-lockitron
Now I think we need to alter the config.json
But what do we adjust? The install plugin section references
Plugins can publish Accessories and/or Platforms. Accessories are individual devices, like a smart switch or a garage door. Platforms act like a single device but can expose a set of devices, like a house full of smart lightbulbs.
Looking into the source of lockitron we can see the values required.
Adjusted config
{
"bridge": {
"name": "Homebridge",
"username": "CC:22:3D:E3:CE:30",
"port": 51826,
"pin": "031-45-154"
},
"description": "Config file with just lockitron",
"accessories": [
{
"accessory": "Lockitron",
"name": "homebridge-lockitron"
}
]
}
Now to run homebridge
again.
Success, now to figure out the app section.
If you are a member of the iOS developer program, I highly recommend Apple's HomeKit Catalog app, as it is reliable and comprehensive and free (and open source).
I downloaded the code and loaded it in Xcode.
Pressing play was of no luck as I ran into a few issues.
No matching provisioning profiles found: None of the valid provisioning profiles allowed the specified entitlements: com.apple.external-accessory.wireless-configuration, com.apple.developer.homekit.
On the capabilities tab for the project file clicking fix issue did resolve the one issue but still ran into the problem of App ID with identifier .... is not available.
Over to stack overflow this answer seemed promising. I went to the general tab on the project file, came up with a new bundle identifier, back to the capabilities tab, and clicked fix issue. Wonderful! all issues should now be fixed, let's press play.
It is running! now what?
- Inside of the app I added a new home
- Added a new accessory which discovered homebridge
- I had to type in the code manually, the camera might have worked but this was easier.
We now appear to be all linked together. If I go under the control tab of the app and adjust the lockitron state I receive the expected errors in the terminal window where homebridge
is running. I think the first phase of this process is complete.
Mental recap
homebridge
is fairly easy to get setup once the pieces are installed- app id's need to be unique and clicking fix issue most of the time will fix your issue
- I am curious how to interact with home kit devices with siri.
Cover image credit: http://facebook.com/RodrigoMoraesPhotography