Raspberry Pi Setup

For all methods from "Overview", the first thing you need to do is set up a Raspberry Pi. To set up Raspberry Pi you could use our "ready to use" image in "Preinstalled image" section or install all software directly in "Manual installation" section.

Preinstalled image

The easiest way to setup you Raspberry is to use our prepared image. For downloading it, we will use IPFS. For this install IPFS and start it (Don't forget to make ipfs init for the first start):

ipfs daemon

In other terminal window download image:

Alternatively, you can download it from url. (Only with started IPFS Daemon), but then you

ipfs get Qmb1hkvDjDbruHUkjPKf4qN2cyqtR7Lr9i3BUwwmNxxTiH -o rpi.img.xz

Then read the next chapter to install image.

Configuration RPi

Install balena etcher on your computer. Then, insert the SD card and run the Imager program. Select required image as the operating system and ensure to select your SD card from the storage dropdown, and then flash image.

Balena installer

Open the SD card's storage and navigate inside the root folder of the card. The name of the folder should be something similar to system-boot.

Find the file named network-config and open it in a text editor. Copy the text below and paste it into the file and insert your wi-fi name and wi-fi password:

version: 2
    dhcp4: true
    optional: true
    dhcp4: true
    optional: true
        password: "YOUR_WIFI_PASSWORD"
Make sure that you input your actual Wi-Fi name and your Wi-Fi password.

Then you need to save the file, and insert the SD card to the Raspberry Pi and turn it on. It should connect to your wi-fi network.

Now you need to find its address. To find address you can use Fing app. You can also find an RPi address with a nmap tool. Install it with:

    sudo apt-get install nmap
    brew install nmap

    Then find your address in the local network with:

      ip a

      It should look like 192.168.xx.xx or 172.xx.xx.xx.

      Then scan your network as shown below replacing the last octet of the address with 0. (One may also use arp -a ):

      $ sudo nmap -sP 192.168.xx.0/24
      Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-26 13:50 CEST
      Nmap scan report for _gateway (
      Host is up (0.015s latency).
      MAC Address: 8E:F5:A3:DB:03:27 (Unknown)
      Nmap scan report for ubuntu (
      Host is up (0.049s latency).
      MAC Address: DC:A6:32:02:46:50 (Raspberry Pi Trading)
      Nmap scan report for LAPTOP-27UBLNO7 (
      Host is up (0.00057s latency).
      MAC Address: 7C:B2:7D:9E:95:DA (Intel Corporate)
      Nmap scan report for ed-vm (
      Host is up.
      Nmap done: 256 IP addresses (4 hosts up) scanned in 2.07 seconds

      In this example the Raspberry Pi's address is Now connect to it over ssh:

      User is "ubuntu". Password is "ubuntu".
      ssh ubuntu@

      If you have already installed our "ready to use" image, then go to the next article MQTT Broker. Otherwise, continue manual installation.

      Manual Installation

      If It's necessary, you can create PRi image manually. For this you should choose 64-bit Ubuntu Server 22.04 LTS or newer and then repeat Configuration RPi.

      Home Assistant installation

      Now we need to install Home Assistant to the Raspberry Pi. Official website of Home Assistant can be found here.

      We will install Home Assistant Core. Its actual version is 2022.8.2 and instruction assumes that you already have Python 3.9 or newer installed.

      Let's start. The easiest way is to use our bash script install.sh to update system and install all dependencies automatically. Download file to your Raspberry Pi. Then change user's rights for this file and start it:

      curl -O https://raw.githubusercontent.com/LoSk-p/robonomics-hass-utils/main/raspberry_pi/install.sh
      chmod a+x install.sh
      bash install.sh

      During installation process you will see the next request:

      RPI installer

      Just choose ok with tab button and press enter. After script work is finished, go to the next article - MQTT Broker.

      Alternatively, you can do all the job manually.

      Update your system and install necessary packages:

      sudo apt-get update
      sudo apt-get upgrade -y
      sudo apt-get install -y python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 tzdata libcurl4-openssl-dev subversion

      Create user homeassistant and the directory for homeassistant core:

      sudo useradd -rm homeassistant
      sudo mkdir /srv/homeassistant
      sudo chown homeassistant:homeassistant /srv/homeassistant

      Next step is to create and switch to a virtual environment for Home Assistant Core. This should be done as the homeassistant user.

      sudo -u homeassistant -H -s
      cd /srv/homeassistant
      python3 -m venv .
      source bin/activate
      terminal image

      Then install required Python packages:

      (homeassistant) homeassistant@ubuntu:/srv/homeassistant/python_scripts$ python3 -m pip install wheel
      (homeassistant) homeassistant@ubuntu:/srv/homeassistant/python_scripts$ pip3 install sqlalchemy fnvhash
      (homeassistant) homeassistant@ubuntu:/srv/homeassistant/python_scripts$ pip3 install homeassistant==2022.8.2

      Start Home Assistant Core for the first time. This will complete the installation for you,by automatically creating the .homeassistantconfiguration directory in the /home/homeassistant directory, and installing any basic dependencies:

      (homeassistant) homeassistant@ubuntu:/srv/homeassistant/python_scripts$ hass

      You can now reach your installation via the web interface on http://%RASPBERRY_IP_ADDRESS%:8123. In this example:

      You don't need to connect you raspberry to the monitor, you can open Web UI from any computer connected to your local network.

      Wait until you will get "Hello window" in browser and then stop Home Assistant with Ctrl+C.

      IPFS installation

      Also, we need IPFS for working with robonomics. As for the latest release of IPFS is 0.12.2. You can use our script to download ipfs and create systemd service with it.

      (homeassistant) homeassistant@ubuntu:/srv/homeassistant/python_scripts$ exit
      cd ~
      wget https://raw.githubusercontent.com//airalab/homeassistant-robonomics-integration/main/install_ipfs.sh
      sudo chmod +x install_ipfs.sh

      Zigbee2MQTT setup

      Now install necessary software for Zigbee2MQTT sticks:

      # Set up Node.js repository and install Node.js + required dependencies
      # NOTE: Older i386 hardware can work with [unofficial-builds.nodejs.org](https://unofficial-builds.nodejs.org/download/release/v16.15.0/ e.g. Version 16.15.0 should work.
      sudo curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
      sudo apt-get install -y nodejs git make g++ gcc
      # Verify that the correct nodejs and npm (automatically installed with nodejs)
      # version has been installed
      node --version  # Should output v14.X, V16.x, V17.x or V18.X
      npm --version  # Should output 6.X, 7.X or 8.X
      # Create a directory for zigbee2mqtt and set your user as owner of it
      sudo mkdir /opt/zigbee2mqtt
      sudo chown -R ${USER}: /opt/zigbee2mqtt
      # Clone Zigbee2MQTT repository
      git clone --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
      # Install dependencies (as user "pi")
      cd /opt/zigbee2mqtt
      npm ci

      Note that the npm ci could produce some warning which can be ignored.

      Systemd services

      If you don't want to start Home assistant manually everytime, create systemd service.

      Create new service for Home Assistant to start:

      ubuntu@ubuntu:~$ sudo nano /etc/systemd/system/home-assistant@homeassistant.service 

      Paste the following:

      Description=Home Assistant
      ExecStart=/srv/homeassistant/bin/hass -c "/home/%i/.homeassistant"

      After that enable and start the service:

      sudo systemctl enable home-assistant@homeassistant.service
      sudo systemctl start home-assistant@homeassistant.service

      Add custom integration

      Integrations allow Home Assistant to record datalogs with encrypted data from Home Assistant and listen to launch commands to control smart devices. Integrations use IPFS to store data and send IPFS hash in datalog or launch.

      On your Raspberry Pi with Home Assistant log in homeassistant user:

      sudo -u homeassistant -H -s

      Source virtual environment and install python packages:

      source /srv/homeassistant/bin/activate
      pip install robonomics-interface~=1.3

      Then go to .homeassistant directory:

      cd /home/homeassistant/.homeassistant

      Create folder custom_components and clone in there the repository with the integration:

      mkdir custom_components
      cd custom_components
      svn checkout https://github.com/airalab/homeassistant-robonomics-integration/trunk/custom_components/robonomics

      After that exit Home Assistant user and restart service:

      sudo systemctl restart home-assistant@homeassistant.service

      That's all. Next step is to install MQTT Broker.

      previous ← Overview next MQTT Broker setup →