Tag Archives: homebridge

Homebridge & Retiring the WUnderground API

With the retirement of the Weather Underground API, I needed to make some changes to my homebridge configuration.

I’ve been using the homebridge-weather-station-extended module to show the outside weather, but that seems to be abandoned, and only offers support for the Weather Underground API. As an alternative, I found the homebridge-weather-plus module. homebridge-weather-plus supports the Dark Sky API, the OpenWeatherMap API, and the Yahoo weather API, in addition to the Weather Underground.

In the end, the configuration was dead simple, per the project’s readme. I added this to my config.json, replacing the XXXs with my API key, and the lat and long with appropriate values:

"platforms": [
    {
        "platform": "WeatherPlus",
        "name": "WeatherPlus",
        "service": "darksky",
        "key": "XXXXXXXXXXXXXXXX",
        "locationGeo": [lat, long],
        "language": "en",
        "units": "imperial",
        "forecast": [1,2,3,4,5,6,7]
    }
]

And with that, I have weather forecasts available to me in the home app again:

Screen capture from macOS Home app

homebridge-camera-rpi

With the recently released homebridge-nest-cam plugin, my old Dropcam has new life in HomeKit. This, combined with Steve Troughton-Smith’s tweets about the Pi Zero W, has sparked a desire to setup additional HomeKit cameras.

I ordered a Pi Zero W Camera Pack, and set about following Wojtek Pietrusiewicz’s instructions for configuring it with homebridge-camera-rpi.

It was easy to get the Pi connected to the network, but I ran into trouble when I needed to install ffmpeg. I couldn’t get it working, and based on some comments, I think it may be fairly difficult to install. I’m speculating that something changed between the Rasbian Stretch image of November 2017 and the image of March 2018.

Instead, I used the pre-built image of homebridge-camera-rpi. After using Etcher to flash the image onto my microSD card, the only modifications I made were to the /wpa_supplicant/wpa_supplicant-wlan0.conf file to add my network SSID and passkey, and to tweak the settings of the plugin in /homebridge-camera-rpi.conf.json.

With that, I was able to see the Pi on the network (via Lanscan), and add it in the Home app.

Home App Screenshot

Bose SoundTouch and HomeKit

I had so much fun with my previous HomeBridge adventure that I went looking for additional plug-ins I could add. I found the HomeBridge SoundTouch plugin, and installing it could not have been easier.

First, I killed the homebridge process:

launchctl unload ~/Library/LaunchAgents/com.homebridge.server.plist

Then, I downloaded the plugin:

sudo npm install -g homebridge-soundtouch

Finally, I had to modify my config.json file (~/.homebridge/config.json). I included this before the final }:

"accessories": [
        {
            "accessory": "SoundTouch",
            "name": "Kitchen Speaker",
            "room": "Kitchen"
        }
    ]

(Kitchen is the name of the speaker as configured in the Soundtouch app, and Kitchen Speaker is how I want it to appear in HomeKit. The word speaker may seem redundant, but it’s useful, since HomeKit doesn’t actually know it’s a speaker — it just thinks it’s a dumb switch.)

Finally, I restarted the homebridge process:

launchctl load ~/Library/LaunchAgents/com.homebridge.server.plist

Chamberlain MyQ and HomeBridge

Evan at 40tech.com wrote up instructions for configuring the Chamberlain MyQ system with HomeKit. Since Chamberlain still hasn’t released official support for HomeKit, you can use HomeBridge as an intermediary between iOS and the official Chamberlain API. Homebridge requires a computer (or Raspberry Pi) to be running on your home network; in my case, my always-on iMac fits the bill.

Homebridge is fairly easy to setup, especially if you already have Homebrew and Node.js on your computer. I ran into a few issues with my Homebrew installation after the upgrade to Sierra, so I decided to start with a fresh install.

Installing Homebrew and Node.js

You can follow the instructions here to install Homebrew. The basic installation command is:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

This guide suggests adding the Homebrew location to your ~/.bash_profile, and I found that helpful for the Node installation:

export PATH="/usr/local/bin:$PATH"

With Homebrew, you can now install node:

brew install node

Installing HomeBridge

Node brings with it npm, the Node Package Manager. You can use this to install HomeBridge and the LiftMaster2 plugin:

sudo npm install -g homebridge
sudo npm install -g git+https://github.com/luisiam/homebridge-liftmaster2.git

If you see warnings, you can try adding the flag –unsafe-perm to each npm call above. I believe having the Homebrew location on the path prevented me from seeing any warnings, but I’m not sure.

You can now try running HomeBridge:

homebridge

It should start up, and you’ll see a message about not having a configuration file installed. It will look for the file here:

nano ~/.homebridge/config.json

Evan provided his configuration file contents:

{
"bridge": {
"name": "Homebridge",
"username": "CC:22:3D:E3:CE:30",
"port": 51826,
"pin": "031-45-154"

},

"description": "JSON API",
"platforms": [{
"platform": "LiftMaster2",
"username": "me@email.com",
"password": "password"
}]
}

You’ll need to replace the username and password in the config.json file with your MyQ credentials. You can now try running homebridge again, and you should see a successful connection! You can add the bridge to the HomeKit database on your phone through the Home app.

Configuring launchd to Keep HomeBridge Alive

If you want to make sure HomeBridge is always running on your Mac, you can use these instructions to configure a Launch Agent.

You’ll need to create a plist file for the agent; I saved mine as ~/Library/LaunchAgents/com.homebridge.server.plist. The file contents should be:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.homebridge.server</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/homebridge</string>
        <string>-I</string>
    </array>
    <key>EnvironmentVariables</key>
    <dict>
            <key>PATH</key>
            <string>/usr/local/bin/:$PATH</string>
    </dict>
</dict>
</plist>

This will start HomeBridge when your computer boots, and restart it if it dies. To manually start the process:

launchctl load ~/Library/LaunchAgents/com.homebridge.server.plist

And to stop it:

launchctl unload ~/Library/LaunchAgents/com.homebridge.server.plist

Next…

Now HomeBridge should be up and running, and you should be able to control your MyQ devices from Siri and Home on iOS. Next up, I want to tackle adding HomeKit support for my Nest devices.