Skip to content

Instantly share code, notes, and snippets.

@alfg
Last active May 1, 2019 19:53
Show Gist options
  • Save alfg/abf26d670a2c6078a2de2144cdb8b675 to your computer and use it in GitHub Desktop.
Save alfg/abf26d670a2c6078a2de2144cdb8b675 to your computer and use it in GitHub Desktop.
Raspberry PI Homebridge Install

Instructions

Download and Install Raspbian Stretch

Get the latest copy of Raspbian Stretch from the official Raspberry Pi website and image this to your SD card.

Raspbian Stretch Lite is prefered as there is no need to run a GUI desktop.
How to install Raspberry Pi Operating System Images

Configure Raspbian for Headless Boot

By default SSH access and WiFi are disabled in Raspbian. You can enable both these services before we boot from the SD card for the first time - this will avoid the need to ever connect a screen to the Pi.

The following changes to the freshly imaged SD card should be made on your computer before you plug the card into the Raspberry Pi for the first time. Enable SSH

To enable remote SSH access on first boot create an empty file called ssh in the root of the SD card. Enable WiFi (Optional)

If you have a Raspberry Pi with built in WiFi (Pi 3 or Zero W), you can configure WiFi on first boot. To do this create a file named wpa_supplicant.conf in the root of the SD card that contains the following (replace the YOUR_COUNTRY_CODE, YOUR_SSID and YOUR_PASSWORD values):

country=YOUR_COUNTRY_CODE ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1

network={ ssid="YOUR_SSID" scan_ssid=1 psk="YOUR_PASSWORD" key_mgmt=WPA-PSK }

Login

Power on your Raspberry Pi and connect to the console using SSH.

If you're running macOS or have Bonjour for Windows (part of iTunes) installed, you should be able to connect using raspberrypi.local as the hostname. If not then you'll need to find out what IP address the Raspberry Pi was assigned and connect using that instead.

ssh [email protected]

The default username is pi and password raspberry. You should change the default password now using the passwd command.

Install

Follow homebridge install instructions on:

sudo npm install -g --unsafe-perm homebridge-config-ui-x
  • Install FFMPEG + homebridge camera
sudo apt-get install ffmpeg
npm install -g homebridge-camera-ffmpeg
  • If using raspberry pi camera module:
sudo raspi-config # Enable camera in 5. Interfacing Options
sudo rpi-update
sudo modprobe bcm2835-v4l2
  • Sample config in ~/.homebridge/config.json
{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:30",
        "port": 51826,
        "pin": "031-45-154"
    },

    "description": "Test description.",

    "accessories": [
    ],

    "platforms": [
        {
          "platform": "config",
          "name": "Config",
          "port": 8080,
          "sudo": false
        },
        {
          "platform": "Camera-ffmpeg",
          "cameras": [
                {
                  "name": "Main Cam",
                  "videoConfig": {
                      "source": "-f v4l2 -r 30 -s 1280x720 -i /dev/video0",
                      "maxStreams": 2,
                      "maxWidth": 1280,
                      "maxHeight": 720,
                      "maxFPS": 30,
                      "vcodec": "h264_omx"
                  }
                }
            ]
        }
    ]
}
  • Start homebridge
homebridge

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment