# Sonoff ZigBee Tasmota and Node Red

**URL:** <https://discourse.nodered.org/t/sonoff-zigbee-tasmota-and-node-red/46036>\
**Category:** General\
**Created:** [21 May 2021 13:56 UTC](https://discourse.nodered.org/t/sonoff-zigbee-tasmota-and-node-red/46036 "2021-05-21T13:56:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![foskolo](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@foskolo](https://discourse.nodered.org/u/foskolo)\
**Post date:** [21 May 2021 13:56 UTC](https://discourse.nodered.org/t/sonoff-zigbee-tasmota-and-node-red/46036/1 "2021-05-21T13:56:19Z")

</div>

Hi,

I’m tying to use some Sonoff ZigBee switches with a Sonoff ZigBee bridge with Tasmota.

I flashed Tasmota in the brigde and I paired two Sonoff switches whit it. All works fine. When I press a switch I see in the bridge console the information coming from it.

My problem is: how can I **distinguish** the single switches in Node Red?

I try to explain what I mean.

I gave the two switches two “friendly names” for the two espresso machines I want to switch on with them (with the commands: “ZbName 0x85AE, Rancilio1” and “ZbName 0x2ABA, Rancilio2”).

Then I used a MQTT input node with the topic “ZbTasmota/tele/SENSOR”, a Json node and a debug node:

[{"id":"49159c60.270e1c","type":"mqtt in","z":"bca0d3e2.0e7bb8","name":"","topic":"ZbTasmota/tele/SENSOR","qos":"2","datatype":"json","broker":"b8ea3341.dc51","x":200,"y":130,"wires":[["e31d5195.a97f38","88da732e.96e978"]]},{"id":"e31d5195.a97f38","type":"json","z":"bca0d3e2.0e7bb8","name":"JSON","x":360,"y":210,"wires":[["8e3f7a6c.a76ad","84f6f1d8.26144","20ffd9e2.e7452e"]]},{"id":"20ffd9e2.e7452e","type":"debug","z":"bca0d3e2.0e7bb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":620,"y":90,"wires":},{"id":"b8ea3341.dc51","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

When I press the Sonoff switch 1 in the debug windows I see

{"ZbReceived":{"0x85AE":{"Device":"0x85AE","Name":"Rancilio1","0006!02":"","Power":2,"Endpoint":1,"LinkQuality":107}}}

And when I press switch 2 I see:

{"ZbReceived":{"0x2ABA":{"Device":"0x2ABA","Name":"Rancilio2","0006!02":"","Power":2,"Endpoint":1,"LinkQuality":107}}}

How can I (with a function node or with a switch node e.g.) activate different devices or in other words how can I extract the “Name” of the Switches from the Json string?

Thank you!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [21 May 2021 14:44 UTC](https://discourse.nodered.org/t/sonoff-zigbee-tasmota-and-node-red/46036/2 "2021-05-21T14:44:08Z")

</div>

This topic was about the same thing it should have all you need

> [@Parsing nested object with wildcard](https://discourse.nodered.org/t/parsing-nested-object-with-wildcard/45802):
>
> I have a series of incoming MQTT messages which I use a JSON node to convert to an object. When I only had a few devices I used a Switch node to separate each device but it's getting unwieldy. A sample message is "{"ZbReceived":{"Laser":{"Device":"0x1FFC","Name":"Laser","Power":0,"Endpoint":1,"LinkQuality":39}}}" The problem I have is that 'Laser' varies for each device so I also get "{"ZbReceived":{"Front":{"Device":"0x8664","Name":"Front","Illuminance":31630,"Endpoint":2,"LinkQuality":39}}…

[edit There are 4 example flows and the finished flow from the OP is in post 17 and the first example shows how to capture the device name

And here is another example just using the Name

```auto
[{"id":"d461676b.baf408","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"ZbReceived\":{\"0x85AE\":{\"Device\":\"0x85AE\",\"Name\":\"Rancilio1\",\"0006!02\":\"\",\"Power\":2,\"Endpoint\":1,\"LinkQuality\":107}}}","payloadType":"json","x":150,"y":1040,"wires":[["2880133b.ff063c"]]},{"id":"2880133b.ff063c","type":"switch","z":"c74669a0.6a34f8","name":"","property":"payload.ZbReceived.*.Name","propertyType":"jsonata","rules":[{"t":"eq","v":"Rancilio1","vt":"str"},{"t":"eq","v":"Rancilio2","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":1060,"wires":[["a5a711f3.437f4"],["f94ef796.4bf5f8"]]},{"id":"9e6228b0.30b6f8","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"ZbReceived\":{\"0x2ABA\":{\"Device\":\"0x2ABA\",\"Name\":\"Rancilio2\",\"0006!02\":\"\",\"Power\":2,\"Endpoint\":1,\"LinkQuality\":107}}}","payloadType":"json","x":140,"y":1100,"wires":[["2880133b.ff063c"]]},{"id":"a5a711f3.437f4","type":"debug","z":"c74669a0.6a34f8","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":520,"y":1040,"wires":[]},{"id":"f94ef796.4bf5f8","type":"debug","z":"c74669a0.6a34f8","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":510,"y":1080,"wires":[]}]

```

]

---

<div class="post-metadata">

**Author:** ![foskolo](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@foskolo](https://discourse.nodered.org/u/foskolo)\
**Post date:** [21 May 2021 15:11 UTC](https://discourse.nodered.org/t/sonoff-zigbee-tasmota-and-node-red/46036/3 "2021-05-21T15:11:26Z")

</div>

Hi,

can you please post the eintire flow of your solution?  
Thank you!

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [22 May 2021 06:04 UTC](https://discourse.nodered.org/t/sonoff-zigbee-tasmota-and-node-red/46036/4 "2021-05-22T06:04:24Z")

</div>

Make sure to read the documentation and [how to work with messages](https://nodered.org/docs/user-guide/messages)
