Raspberry Pi Zero W
This page will guide you through setting up a Pi Zero W to run room-assistant.
- Raspberry Pi Zero W + Power Supply
- Micro SD Card (ideally Application Class 1)
- SD Card reader
- Put your microSD card into your card reader.
- Open the Raspberry Pi Imageropen in new window and select the following options:
- OS -> Raspberry Pi OS (other) -> Raspberry Pi OS (Lite)
- SD Card -> the SD card you put into your card reader
- Open the advanced options (Windows: Ctrl + Shift + X, macOS: Cmd + Shift + X) and enable SSH. Optionally, you can configure WiFi credentials, the hostname to be something recognizable like
bedroomand more in this same menu. Hit "Save" on the bottom after you're done.
- Write the image to the card from the main menu. Wait for it to be finished before removing the card from the reader.
- Insert the SD card into your Raspberry Pi Zero W, then connect the power supply. Wait a minute for it to boot and connect to your network.
- Open a SSH shell to
raspberrypi.local) with the user
piand the password you configured (default:
raspberry). On Windows you can use Puttyopen in new window, with Linux and macOS you can just open the terminal and e.g. type
ssh firstname.lastname@example.org. If the hostname is not found, use the IP of the Pi instead - it can be found in your router administration panel.
Now we install NodeJS by running
wget -O - https://gist.githubusercontent.com/mKeRix/88b7b81e9bca044f74de1dc51696efb2/raw/799a20bca44cc61d8f8ae93878f2f28af8365a69/getNodeLTS.sh | bash1
To make the commands we install with npm available the $PATH environment variable needs to be extended as well. Edit the file
nano ~/.profile) and add the
PATH="$PATH:/opt/nodejs/bin"to the end of the file. Save, then run
We need to install some other dependencies as well, do so by running
sudo apt-get update && sudo apt-get install build-essential libavahi-compat-libdnssd-dev libsystemd-dev bluetooth libbluetooth-dev libudev-dev libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev.
Now let's get install room-assistant! Run
sudo npm i --global --unsafe-perm room-assistant. You will see messages like the one shown below during the installation process. Don't worry about them - they're not errors!
Optional: If you want to run Bluetooth related integrations, you should also grant some additional permissions by executing the commands below.
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`) sudo setcap cap_net_raw+eip $(eval readlink -f `which hcitool`) sudo setcap cap_net_admin+eip $(eval readlink -f `which hciconfig`)1
Create a config folder for room-assistant with
mkdir -p ~/room-assistant/config.
Create a new config file with
nano ~/room-assistant/config/local.ymland put your room-assistant configuration in it. The example below configures the Home Assistant Core and Bluetooth Classic integrations. If you want to use something else check out the integrations section.
global: integrations: - homeAssistant - bluetoothClassic homeAssistant: mqttUrl: 'mqtt://homeassistant.local:1883' mqttOptions: username: youruser password: yourpass bluetoothClassic: addresses: - <bluetooth-mac-of-device-to-track>1
Go to your room-assistant directory by executing
Run room-assistant by executing
room-assistant. Watch the logs - are all integrations are loaded correctly and is the MQTT connection succesful? Then congratulations, you configured room-assistant correctly! 🎉 New entities should now be appearing under the MQTT integration in Home Assistant Core, which can be viewed in Settings > Integrations.
When starting room-assistant you will see warnings about the Apple Bonjour compatibility layer of Avahi. These won't impact the functionality at all and can just be ignored.
Making sure it always runs
If room-assistant is still running from the previous step, stop it by hitting Ctrl + C on your keyboard.
Create a file using
sudo nano /etc/systemd/system/room-assistant.servicewith the following contents:
[Unit] Description=room-assistant service [Service] Type=notify ExecStart=/opt/nodejs/bin/room-assistant WorkingDirectory=/home/pi/room-assistant TimeoutStartSec=120 TimeoutStopSec=30 Restart=always RestartSec=10 WatchdogSec=60 User=pi [Install] WantedBy=multi-user.target1
Enable and start your service by executing the commands below.
sudo systemctl enable room-assistant.service sudo systemctl start room-assistant.service1
Congratulations, you are done! 🎊 You may check the status of the service at any time with
sudo systemctl status room-assistant. room-assistant will now be started when the Pi Zero W boots.