Subscribing to Zigbee2MQTT with Node-RED
This blog will cover the topic of Creating a Node-RED flow to subscribe messages to the MQTT broker used by Zigbee2MQTT. Please install both Node-RED and Zigbee2MQTT before reading further.
Creating the Node-RED flow
After you run your Node-RED and go to you Node-RED frontend, you will be able to create your Node-RED flow.
The nodes that we will use to subscribe to the MQTT broker used by Zigbee2MQTT is the mqtt in nodes.
Then we are going to look at the messages recieved from the nodes with the debug nodes.
Connect the mqtt in node’s output to a Debug node to view the massage recieved from the MQTT broker.
Setting up each mqtt in node’s properties
Set the topic property to the same topic that the Zigbee end device uses to publish information to the MQTT broker, usually zigbee2mqtt/(The device’s IEEE address)
Set the output property to any option base on what you need to do with the output.
Now we have to let Node-RED knows what MQTT server are we going to subscribe to. Do this by adding a new mqtt broker.
After selecting the Add a new MQTT broker option, click the pencil button.
Set the server property to the server that hosts the MQTT broker.
Setting up each debug node’s properties
You can either see the whole msg object or its payload. The information we want to see is in the payload.
Deploying the flow
After you finish editing your Node-RED flow, press the Deploy button located on the top right of your screen.
Now you can see the messages the Zigbee end device publish to the MQTT broker in your debug window.