Let SPM Empower Your Home: A Guide to Home Assistant and Zigbee2MQTT Configuration

Dec 21, 2023 | Applications, Tutorials

In this blog post, we will delve into Home Assistant and its powerful add-on Zigbee2MQTT, while showcasing our cutting-edge smart meters—SPM01 & SPM02. I will guide you through the process of configuring Zigbee2MQTT and integrating our SPM devices into Zigbee2MQTT for use in Home Assistant. Let’s step into the world of seamlessly integrated smart homes through Home Assistant, Zigbee2MQTT, and SPM.

Watch the video guide instead >>

I.Home Assistant: The one-stop smart home platform

Home Assistant is an open-source smart home platform that provides users with a powerful solution for integrating and automating various smart devices. Whether you’re a beginner or an expert, Home Assistant offers comprehensive and flexible home control.

Home Assistant offers a range of installation methods, each accompanied by detailed instructions available on its official website. You can visit the installation guide on its official website and choose the method that best suits you for installation.

After several updates and optimizations, configuring Home Assistant is no longer a daunting task of endless YAML file edits. The refined UI interface makes it easier for users to configure Home Assistant.

II.MQTT Integration & Mosquitto broker

Before introducing Zigbee2MQTT, it’s essential to understand two other plugins in Home Assistant: Mosquitto Broker and MQTT Integration.

1. Mosquitto Broker

Eclipse Mosquitto is an open-source (EPL/EDL license) message broker that implements MQTT protocol versions 5.0, 3.1.1, and 3.1. Mosquitto is lightweight and suitable for use on various devices, from low-power single-board computers to full servers.

Mosquitto provides users with a local MQTT broker, installed in Home Assistant as an add-on, eliminating the need for users to set up their MQTT servers. However, if you have your own MQTT server, you can skip this part and proceed with Zigbee2MQTT installation and configuration.

Follow these steps to get the add-on installed on your system:

(1) Navigate in your Home Assistant frontend to Settings -> Add-ons -> Add-on store.
(2) Find the “Mosquitto broker” add-on and click it.
(3) Click on the “INSTALL” button.

How to use:

After installation, go to the Mosquitto broker page, and select Configuration at the top.

In the Logins section, enter the MQTT username and password. You can choose any name, but ensure the correct format. This completes the Mosquitto broker configuration. Go back to the info page and click ‘START’ to launch Mosquitto broker.

2. MQTT Integration

MQTT Integration provides a platform for users to listen to or publish data in Home Assistant. If you only need to view data in Zigbee2MQTT, you can skip this part and proceed with Zigbee2MQTT installation and configuration.

Follow these steps to get the Integration installed on your system:

(1) Navigate in your Home Assistant frontend to Settings -> Devices & Services -> Add INTEGRATION.
(2) Find the “MQTT” integration and click it.
(3) Configure the integration

How to use:

If you have your own MQTT server, fill in the Broker, Port, Username, and Password with your server information. If you use Mosquitto broker, fill in ‘’ for Broker, ‘1883’ for Port, and enter the Username and Password you set in the previous step.

After filling in the details, click Next and Submit.


Zigbee2MQTT is a Home Assistant add-on focused on integrating various Zigbee devices into the system. With Zigbee2MQTT, you can easily connect and control a variety of smart devices, creating a smarter and more convenient home experience. It can be installed as a standalone system in Docker or on a Raspberry Pi, but it also comes in an add-on form for easy integration with Home Assistant. This allows users to leverage their Zigbee devices for multifaceted interactions within Home Assistant. In this blog post, I will share how to configure Zigbee2MQTT and integrate our SPM devices into Zigbee2MQTT.


(1) Go back to the Add-on store, click ⋮ → Repositories, fill in https://github.com/zigbee2mqtt/hassio-zigbee2mqtt and click Add → Close or click the Add repository button below, click Add → Close (You might need to enter the internal IP address of your Home Assistant instance first).

(2) Navigate in your Home Assistant frontend to Settings -> Add-ons -> Add-on store.
(3) Find the “Zigbee2MQTT” add-on and click it.
(4) Click on the “INSTALL” button.

How to use:

After installation, go to the Zigbee2MQTT page, and select Configuration at the top.

(1) In the ‘mqtt’ section, enter the relevant information for your MQTT server in the following format:

  • server: mqtt://localhost:1883
    user: my_user
    password: “my_password”

If you use your own MQTT server, fill in the server information accordingly. If you use Mosquitto broker, replace ‘localhost’ with your Home Assistant’s IP address. Enter the User and Password you set when configuring Mosquitto broker.

(2) In the ‘serial’ section, enter information about the Dongle you are using in Home Assistant. The Port is the port used by the Dongle, e.g., port: /dev/ttyUSB0.
If you don’t know the port and you have just one USB device connected to your machine try /dev/ttyUSB0. Else use the Home Assistant CLI and execute ha hardware info to find out.
* If you are using Sonoff’s ZBDongle-E, please add adapter: ezsp in the ‘serial’ column.

(3) Return to the info page and click ‘START’ to launch Zigbee2MQTT.

After ensuring a successful startup, click OPEN WEB UI to access the Zigbee2MQTT page.

Now, you can start pairing our SPM devices:

(1) Press the reset button for 3~5 seconds till the LED is quickly flashing to enter the pairing mode.
(2) Enter WEB UI and click “Allow adding new devices” in the upper right corner to enter pairing mode.
(3) During pairing mode, Zigbee2MQTT will scan all Zigbee devices and automatically add them.
Once paired, the SPM will be displayed on the page, showing its Name, IEEE Address, Manufacturer, Model, and LQI.

Click on the device name to access detailed information.

Click ‘expose’ to view all measurement values of the device.

If Zigbee2MQTT displays “Cannot recognize this device,” it indicates a need to update the configuration file for SPM. To resolve this issue, you can manually add an external converter by following the latest files and instructions.

IV.Functionalities of the Smart Energy Meter (SPM) within Home Assistant

1. Dashboard display

Next, let’s see what SPM, paired with Zigbee2MQTT, can do in Home Assistant. Go back to MQTT Integration to see all devices integrated into Zigbee2MQTT.

Click on a device to view all its measured data. Click ‘ADD TO DASHBOARD’ to add all parameters to the Dashboard.

Access the Energy interface, select our device for home consumption/generation, enabling Home Assistant to track statistics.
*Note: It may take up to 2 hours for newly added devices to appear on your Energy dashboard.

2. Data management and analysis

Navigate to the History page, select the SPM device, and Home Assistant will present all measured parameters in chart form.

3. Energy management automation

These data can also be used in Home Assistant’s Automations & Scenes and Node-RED.

Choose a device to view all available parameters. Apply them in Automations, combining them with other devices for additional functionalities.


Zigbee2MQTT has its Node-RED nodes for receiving and sending data.

To use nodes with Zigbee2MQTT, we need to set up a bridge first. Fill in the information on the MQTT server correctly to establish a connection between the devices and the MQTT server.

Now, we can use the relevant Zigbee2MQTT nodes in Node-RED. Use the “get” node to retrieve the measured values from our devices.

Node-RED comes with many built-in nodes, such as switch, change, range, etc., to implement some basic logical operations.

In addition, we can also write our own program to process the data.

In the example above, I combined the SPM with a regular Wi-Fi MCB. When the SPM detects a current in the circuit greater than 25A, it triggers the MCB to turn off, thus achieving the purpose of protecting the circuit. Finally, I used a notification node to push this result as a notification to my mobile phone.

In this process, I utilized the “get” node from Zigbee2MQTT to retrieve the current value detected by the SPM. The “switch” node was employed to make a decision based on this value, and the “http request” node was used to control the opening and closing of the MCB.

V. Summary

In conclusion, this article delves into the realm of Home Assistant, guiding readers through the configuration of an SPM on this platform. The step-by-step instructions, involving the essential Zigbee2MQTT and two other add-ons, provide a comprehensive understanding of the seamless integration.

Home Assistant stands out as the cornerstone, empowering the development of a versatile and intelligent home ecosystem. Enhancing this capability, Zigbee2MQTT, a robust Home Assistant add-on, facilitates seamless communication with a diverse range of Zigbee devices, among them the Tuya SPM smart energy meter, providing valuable energy insights for home energy management.

As we look ahead, the future of smart homes holds limitless possibilities with creative automation designs. By continually integrating advanced technologies, we aspire to create homes that are both intelligent and efficient for users in this digital era. Join us on this journey into the new era of smart homes!


Related Posts: