# Zigbee fire alarm MQTT message action

**URL:** https://discourse.nodered.org/t/zigbee-fire-alarm-mqtt-message-action/89076
**Category:** General
**Created:** [29 June 2024 10:04 UTC](https://discourse.nodered.org/t/zigbee-fire-alarm-mqtt-message-action/89076 "2024-06-29T10:04:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)
#### Post date: [29 June 2024 10:04 UTC](https://discourse.nodered.org/t/zigbee-fire-alarm-mqtt-message-action/89076/1 "2024-06-29T10:04:59Z")

</div>

My Zigbee fire alarm sends different MQTT status messages but if there is a fire this is one of the unique messages:

_{"ZbReceived":{"0xCB76":{"Device":"0xCB76","EF00/020F":100,"Endpoint":1,"LinkQuality":87}}}_

To be more precise, the part _"EF00/020F:100"_ is unique.

Can anyone tell me how to set up a (switch?) node so that there is only action when the above message arrives?

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [29 June 2024 10:21 UTC](https://discourse.nodered.org/t/zigbee-fire-alarm-mqtt-message-action/89076/2 "2024-06-29T10:21:17Z")

</div>

Here is a simple flow you can use - node you will feed the switch with the `mqtt-in` data

```auto
[{"id":"bd8d338ef133cb1a","type":"inject","z":"47b962d7577cfddb","name":"100","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"ZbReceived\":{\"0xCB76\":{\"Device\":\"0xCB76\",\"EF00/020F\":100,\"Endpoint\":1,\"LinkQuality\":87}}}","payloadType":"json","x":230,"y":180,"wires":[["6bc9b28b0ed61f0f"]]},{"id":"8431c3d828a36f6e","type":"debug","z":"47b962d7577cfddb","name":"100","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.ZbReceived[\"0xCB76\"][\"EF00/020F\"]","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":180,"wires":[]},{"id":"6bc9b28b0ed61f0f","type":"switch","z":"47b962d7577cfddb","name":"","property":"payload.ZbReceived[\"0xCB76\"][\"EF00/020F\"]","propertyType":"msg","rules":[{"t":"eq","v":"100","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":410,"y":220,"wires":[["8431c3d828a36f6e"],["5e21526f57d9143b"]]},{"id":"920bd8632cb74fd6","type":"inject","z":"47b962d7577cfddb","name":"999","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"ZbReceived\":{\"0xCB76\":{\"Device\":\"0xCB76\",\"EF00/020F\":999,\"Endpoint\":1,\"LinkQuality\":87}}}","payloadType":"json","x":230,"y":240,"wires":[["6bc9b28b0ed61f0f"]]},{"id":"5e21526f57d9143b","type":"debug","z":"47b962d7577cfddb","name":"not 100","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.ZbReceived[\"0xCB76\"][\"EF00/020F\"]","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":240,"wires":[]}]

```

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path/value for any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [29 June 2024 10:21 UTC](https://discourse.nodered.org/t/zigbee-fire-alarm-mqtt-message-action/89076/3 "2024-06-29T10:21:26Z")

</div>

In Node-RED, when trying to work out how to extract data from an object, the easiest way is to add a debug node. Here I simulate what your mqtt-in node would do

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/46e2c6f54f61b8e901b5209e3cb9917c97747825.png)

With the debug output looking like this

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/5/0581b211e22fc3786f131e4a974f377f1943e753.png)

In this grab, the mouse was hovering over the copy path button which you can click to get `payload.ZbReceived["0xCB76"]["EF00/020F"]`.

You can put this into a switch node

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/22f8e186bf1afa54575e5898ab3a0bcb7216ae70.png)

Noting that the output is a number not a string.

Now, there may be a complexity if you have \>1 alarm device and want to trigger on any of them. In that case the `["0xCB76"]` part will be a problem as I assume it represents a specific device.

There are various ways to get around that issue. Personally I would probably use a function node. And if doing that, there really isn't any point in also having a switch, may as well do it all in the function.

```javascript
// Check if msg.payload (optionally) contains ZbReceived
if (msg.payload?.ZbReceived) {
    const zbr = msg.payload.ZbReceived
    if (zbr["EF00/020F"] && zbr["EF00/020F"] === 100) {
        return msg
    }
}

```

---

<div class="post-metadata">

### Author: ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)
#### Post date: [29 June 2024 10:46 UTC](https://discourse.nodered.org/t/zigbee-fire-alarm-mqtt-message-action/89076/4 "2024-06-29T10:46:24Z")

</div>

When I encountered this problem and it did not solve it after a few hours of trying, I posted a message here. It is very nice that there are people to help like in this case.

My "problem" is solved, thank you both for your help!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [13 July 2024 10:47 UTC](https://discourse.nodered.org/t/zigbee-fire-alarm-mqtt-message-action/89076/5 "2024-07-13T10:47:14Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
