By ro3lie on Friday 26 April 2019 22:00 - Comments (8)

Category: -, Views: 5.316

Introduction:

Please notice: Performing the next steps is at own risk. I don't take any responsibility if a CloudKey is bricked due to removing to many packages.

How to install HomeBridge on a UniFi CloudKey Gen1

Step 1: Factory reset/firmware update the CloudKey:

Step 2: Access the UniFi CoudKey by SSH.

Step 3: Cleaning up CloudKey packages and updating the OS/software.



1 sudo dpkg -P unifi code:



1 2 3 4 sudo rm /etc/apt/sources.list sudo rm /etc/apt/sources.list.d/nodejs.list sudo rm /etc/apt/sources.list.d/security.list sudo rm /etc/apt/sources.list.d/ubnt-unifi.list code:



1 vi /etc/apt/sources.list code:



1 2 3 4 5 6 deb http://deb.debian.org/debian stretch main contrib non-free deb-src http://deb.debian.org/debian stretch main contrib non-free deb http://deb.debian.org/debian-security/ stretch/updates main contrib non-free deb-src http://deb.debian.org/debian-security/ stretch/updates main contrib non-free deb http://deb.debian.org/debian stretch-updates main contrib non-free deb-src http://deb.debian.org/debian stretch-updates main contrib non-free code:



1 vi /etc/apt/sources.list.d/nodesource.list code:



1 2 deb https://deb.nodesource.com/node_10.x stretch main deb-src https://deb.nodesource.com/node_10.x stretch main code:



1 cat /etc/apt/sources.list code:



1 2 sudo apt-get update sudo apt-get clean && sudo apt-get clean all && sudo apt-get autoclean && sudo apt-get update code:



1 reboot code:



1 sudo apt-get update && sudo apt-get upgrade code:



1 rm /etc/apt/apt.conf.d/50unattended-upgrades.ucf-dist code:



1 2 sudo apt-get remove freeradius sudo apt-get purge freeradius code:



1 2 3 sudo apt-get purge nodejs npm curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt-get install -y nodejs npm code:

To install HomeBridge follow the next steps:



1 2 3 4 5 6 sudo apt-get install build-essential curl git m4 ruby texinfo libbz2-dev libcurl4-openssl-dev libexpat-dev libncurses-dev zlib1g-dev sudo apt-get install g++ sudo apt-get install git make sudo apt-get install libavahi-compat-libdnssd-dev sudo npm install -g --unsafe-perm homebridge sudo npm install -g --unsafe-perm homebridge-config-ui-x code:



1 sudo homebridge code:



1 sudo vi .homebridge/config.json code:



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 { "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-158" }, "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.", "platforms": [ { "name": "Config", "port": 8080, "theme": "red", "tempUnits": "c", "platform": "config" } ] } code:



1 sudo homebridge code:

Step 5: Configure HomeBridge as a Systemd Service.



1 sudo vi /etc/default/homebridge code:



1 2 3 4 5 6 7 # 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 # If you uncomment the following line, homebridge will log more # You can display this via systemd's journalctl: journalctl -f -u homebridge # DEBUG=* code:



1 sudo vi /etc/systemd/system/homebridge.service code:



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [Unit] Description=Node.js HomeKit Server After=syslog.target network-online.target [Service] Type=simple User=homebridge EnvironmentFile=/etc/default/homebridge # Adapt this to your specific setup (could be /usr/bin/homebridge) # See comments below for more information ExecStart=/usr/bin/homebridge $HOMEBRIDGE_OPTS Restart=on-failure RestartSec=10 KillMode=process [Install] WantedBy=multi-user.target code:



1 which homebridge code:



1 2 3 4 5 sudo mkdir /var/lib/homebridge sudo useradd --system homebridge sudo chown -R homebridge:homebridge /var/lib/homebridge sudo chmod 777 -R /var/lib/homebridge sudo cp .homebridge/config.json /var/lib/homebridge/config.json code:



1 2 3 systemctl daemon-reload systemctl enable homebridge systemctl start homebridge code:



1 systemctl status homebridge code:



1 journalctl -u homebridge code:

Step 6- Setting up a HomeBridge back-up to the MicroSD card:



1 2 sudo mkdir /data/homebridge-backup sudo crontab -e code:



1 0 * * * * rsync -av --delete /var/lib/homebridge/ /data/homebridge-backup/ code:



1 ls /data/homebridge-backup/ code:

You are now done with setting up HomeBridge on a UniFi CloudKey.