Skip to main content

Home Assistant

This documentation provides a step-by-step guide to setting up an Air Quality Monitor using Home Assistant on a Raspberry Pi. The instructions are detailed and designed to be easily followed by anyone, regardless of their technical expertise.

However, it's important to note that this is just one example. You have the flexibility to incorporate a diverse range of devices and sensors into the peaq network. Simply make the necessary changes in the Configuration and include the scripts.yaml, as outlined in step 6.


  • A Raspberry Pi with internet connectivity.

  • An air sensor connected to the Raspberry Pi.

Step 1: Install Node.js using NVM

Before proceeding with the project setup, ensure that Node.js (version 16 or higher) is installed on the Raspberry Pi. We recommend using NVM (Node Version Manager) for this:

  • Install NVM:
curl -o- | bash
  • Install Node.js (version 16 or higher) using NVM:
nvm install 16
nvm use 16

Step 2: Install Home Assistant on Raspberry Pi

Follow the steps provided in the official Home Assistant documentation to install the Docker container version of Home Assistant.

Step 3: Clone the Repository

Clone the repository containing the necessary JavaScript files into the Home Assistant Docker container volume. Replace YOUR_REPO_URL with the actual repository URL:

git clone YOUR_REPO_URL

Step 4: Install PM2

PM2 is a process manager for Node.js applications. Install it globally using npm:

npm install pm2 -g

Step 5: Data Collection

  • Navigate to the directory where you cloned the repository.

  • Run the test.js file using PM2. This script will continuously collect data from the air sensor and save it to a file named data.json:

pm2 start test.js

Step 6: Update Home Assistant Configuration

  • Access the configuration.yaml file inside the Docker container.

  • Add the following shell command to the file:

run_air_quality: 'node /config/pi_air_quality_monitor/main.js'

This command will execute the main.js file, which reads the data from data.json and sends it to our blockchain network.

Step 7: Create a Service in Home Assistant

  • Open the scripts.yaml file.

  • Add the following code to create a service:

alias: "Run_Air"
- service: shell_command.run_air_quality

Step 8: Run the Script

  • Navigate to the Home Assistant interface.

  • Locate the script section and find the Run_Air script.

  • Execute the script.

Step 9: Verify the Data

After running the script, check the event in the polkadot.js explorer to ensure that the data has been sent to the blockchain network.

Expanding Possibilities with the peaq Network

However, it's important to note that this serves as an illustrative example of connecting an Air Quality Monitor with Home Assistant on a Raspberry Pi to the peaq network. With the modification of scripts in steps 6 and 7, you can extend this connectivity to virtually any sensor you wish to integrate with the peaq network.


Following this example, you can integrate a wide range of devices and sensors into the peaq network. The provided steps serve as a versatile framework for expanding the capabilities of your network.