Setting up the Raspberry Pi

In my previous post I explained that I was switching out my Homey Pro for a Raspberry Pi 4. Now that all the hardware is in, it’s time to set everything up! This is what I got:

  • Raspberry Pi 4 (4GB)
  • Official PoE HAT
  • Kingston A2000 NVMe
  • ICY BOX M.2 Case
  • ConBee II


Setting up the hardware.
The first thing to do is screw everything together, as that is super easy, I am not going to explain that. When everything is correctly screwed together, the SSD can be formatted and configured with the Raspberry Pi Imager. Just plug it into the computer, choose the right OS, click next and it’s done. What I do want to mention is that SSH is turned off by default. Creating a file named “SSH” on the boot folder of Raspbian OS activates this again. The next step is plugging everything in and booting up. Since last year, the Raspberry Pi supports booting from USB devices. In case yours does not work yet, try updating the Raspberry Pi to the latest Firmware and EEPROM after booting from an SD card first. Below are the commands to do this but luckily mine was ready to go.

Configuring the basics.
Now that the hardware is plugged in and the Raspberry Pi is booted up, configuring everything is next on the list. Look for the Raspberry Pi on your network, remember it’s IP address and SSH to the device with:
ssh pi@<IP.ADDRESS>

There are a couple of things that need to be done before installing and configuring Pi-Hole and other programs you might want to run on the Raspberry Pi:

# Update the list of programs
sudo apt update

# Upgrade the programmes with all it's dependencies
sudo apt full-upgrade

# Reboot to activate all the changes
sudo reboot

# The next bit should not part of any regular update process!

# Update the OS kernel
sudo rpi-update

# Update the EEPROM to the latest version
sudo rpi-eeprom-update

After this, reboot again and the Raspberry Pi is all up to date.
Changing the default password is also highly recommended. Choose a strong password, you can even make use of a password manager like I do.

sudo passwd

With the basics done, the Raspberry Pi is ready to be used for it’s original goal; Replacing the Homey Pro.

Installing the good stuff.
A few programs are needed to make it all work:
ConBee (DeCONZ)
HomeBridge
Pi-hole (optional)

ConBee:
To connect my Zigbee devices, I use a ConBee II. To read, configure and update the Zigbee stick on the Raspberry Pi, deCONZ is needed.

# Set user USB access rights
sudo gpasswd -a $USER dialout

# Import Phoscon public key
wget -O - http://phoscon.de/apt/deconz.pub.key | \
           sudo apt-key add -

# Configure the Stable APT repository for deCONZ
sudo sh -c "echo 'deb http://phoscon.de/apt/deconz \
            $(lsb_release -cs) main' > \
            /etc/apt/sources.list.d/deconz.list"

# Update APT package list
sudo apt update

# Install deCONZ
sudo apt install deconz

There is one change I made after the installation, which is letting it run on another port than the default one. The reason for this is that deCONZ uses port 80, which is also used for Pi-hole. As Pi-hole overwrites the config file with every update, it’s easier to change the port for deCONZ instead.

# Change directory
cd /lib/systemd/system

# Open file in an editor
sudo nano deconz.service

# Changing the port to 8080
# Look for the following line and replace 80 with 8080 for example
ExecStart=/usr/bin/deCONZ -platform minimal --http-port=8080

# Restarting the service
sudo service deconz restart

# Install Homebridge and Homebridge Config UI X
sudo npm install -g --unsafe-perm homebridge homebridge-config-ui-x

# Setup Homebridge as a service
sudo hb-service install --user homebridge

Now go to <IP.ADDRESS>:8080/pwa/index.html and setup your Zigbee devices.

Does your stick not show up? Make sure you use an USB-Extension cable to decrease the risk of any interference. Especially if you use an external drive connected to other USB ports like I do.

HomeBridge:
HomeBridge is an amazing application to expose non-HomeKit devices to HomeKit. When the Zigbee devices are setup in deCONZ, they need to be exposed to HomeKit too.

# Setup repository
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -

# Install Node.js
sudo apt install -y nodejs gcc g++ make python net-tools

# Test if node is working
node -v

# Upgrade npm
sudo npm install -g npm

Go to http://<IP.ADDRESS>:8581 and install the applications. In my setup I have Nest, Ring and ConBee (uses the Hue app). Make sure to use Verified applications to minimise the risk of security or compatibility issues.

The last step is to connect HomeBridge to HomeKit. Scan the QR-Code from HomeBridge on your iPhone and you are done.

You can see that my sensors appear in HomeKit, just like the Nest Thermostat does. I already made some automations but will add more in the future.

Pi-hole:
The last step is Pi-hole, which is not needed but it’s a great add-on to the Raspberry Pi. I use it as an AdBlocker for all my IoT devices in my network, plus my phones/laptops. And if you don’t want to have ads on your Smart TV, hooks hat one up too! With Pi-hole, you’ll get faster browsing and much more privacy. Check the website to learn more: https://pi-hole.net

# One line install
curl -sSL https://install.pi-hole.net | bash

Just go through the configuration after this and add the Raspberry’s IP as the DNS on your device in settings. Or cover all of your devices in your network and set it as the Router’s DNS server.

And that’s it!

I have replaced my Homey Pro for a Raspberry Pi and got it all working. It’s cheaper, faster and has more possibilities in the future. Let me know in the comments what you think and what you want to see next time.

Happy automating!

© 2024 Schipperus. All rights reserved.