Sonoff ZigBee Tasmota and Node Red

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!

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

[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

[{"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":[]}]

]

Hi,

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

Make sure to read the documentation and how to work with messages