Setting up Homebridge on Raspberry Pi

Hardware Required

  • Raspberry Pi
  • MicroSD
  • SD Card Reader
  • Another computer/ Screen+Keyboard

Software Required

Process

  1. Download latest version of Raspbian and write the image on the SD card using Etcher

  2. Once SD card is ready, install it in the Raspberry Pi and boot the Raspberry Pi

    ​ The default username for Raspbian is pi and the password is raspberry.

  3. Enable SSH on the Pi

    ​ Type sudo raspi-config

    ​ Select Interfaces > SSH > Enable

  4. If using Linux or Mac as your primary computer then you can access the Pi with the following command

    ssh pi@raspberrypi.local

    Or if using Windows, use a utility such as Putty (Download)

  5. Basic setup preparations

    sudo apt-get update

    sudo apt-get upgrade

  6. Install Node

    curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

    sudo apt-get install -y nodejs

  7. Install Homebridge

    sudo npm install -g --unsafe-perm homebridge

  8. Setup Config.json

    sudo nano ~/.homebridge/config.json

    ​ Paste the following in the json file (Feel free to edit the username, port, and pin)

    {
           "bridge": {
                   "name": "Homebridge",
                   "username": "AA:71:3D:E3:CE:10",
                   "port": 51871,
                   "pin": "137-14-151"
           },
           "accessories": [],
           "platforms": []
    }            
    

    ​ Ctrl+X and type Y to save the config.json

  9. Setup to start Homebridge on startup

    ​ 9.1. sudo nano /etc/default/homebridge

    ​ Paste the following

    ## 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/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=*    
    

    ​ 9.2. sudo nano /etc/systemd/system/homebridge.service

    ​ Paste the following​

    [Unit]
    Description=Node.js HomeKit Server 
    After=syslog.target network-online.target
    
    [Service]
    Type=simple
    User=homebridge
    EnvironmentFile=/etc/default/homebridge
    ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS
    Restart=on-failure
    RestartSec=10
    KillMode=process
    
    [Install]
    WantedBy=multi-user.target
    

    ​ 9.3. Create a user to run service sudo useradd --system homebridge

    ​ 9.4. sudo mkdir /var/homebridge

    ​ 9.5. sudo cp ~/.homebridge/config.json /var/homebridge/

    ​ 9.6. sudo cp -r ~/.homebridge/persist /var/homebridge

    ​ 9.7. sudo chmod -R 0777 /var/homebridge

    ​ 9.8. sudo systemctl daemon-reload

    ​ 9.9. sudo systemctl enable homebridge

    ​ 9.10. sudo systemctl start homebridge

    ​ 9.11. systemctl status homebridge to check the status of the service

Homebridge is now running and ready to install plugins

Recommended Plugins

​ Homebridge UX (Link)

sudo npm install -g --unsafe-perm homebridge-config-ui-x

Configuration

​ Add this to your homebridge config.json​

"platforms": [
    {
      "platform": "config",
      "name": "Config",
      "port": 8080,
      "sudo": true,
      "restart": "sudo -n systemctl restart homebridge",
      "log": {
        "method": "systemd",
        "service": "homebridge"
    }
]   

Leave a comment