Sonoff RF Bridge and Node Red approach to receiving data from Tasmota & original firmware

I have been doing a bit of work on my Node red flow which accepts data from two separate Sonoff RF Bridges - one which has been flashed with Tasmota (9.5) and Portisch and the other which is on the original Sonoff firmware (v 3.5)

I have found that recently the format of the data I am getting from the Tasmota(ised) bridge is a little different than originally (this may be when I flashed the portisch firmware, but I can’t be sure as I don’t use this too much, so I haven’t noticed it.

As you can see, I do make use of debug nodes a lot, so probably looks more complex than it really is!

RFBridge 1 is the tasmota(ised) bridge and RFBridge2 is the original Sonoff firmware.

I wanted to put both of the triggers through a single demux function node, so had to run both through a simple convert first.

This isn’t perfect and as I am having problems with RFBridge1 losing connection to wifi, it’s been a bit of a struggle. I need to think about how to deduplicate where both bridges receive the same signal, but am guessing that for me (PIR’s and Door Sensors) it’s really not a big deal.

I’ll add the exported code to post 2.

I have simplified the above flow as follows:

The code is as follows:

[{"id":"a20d7805a1a7f4a6","type":"server-events","z":"af5854af057f3aac","name":"RFBridge2","server":"88793c7799f4c982","version":1,"event_type":"sonoff.remote","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"},{"property":"event_type","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"x":180,"y":280,"wires":[["90741e45ee3f3e52"]]},{"id":"30ee99e846d3ec2b","type":"function","z":"af5854af057f3aac","name":"Demultiplexer","func":"var d = { '0':['buttona','ON','false'],\n '1':['buttonb','ON','false'],\n '2':['buttonc','ON','false'],\n '3':['buttond','ON','false'],\n '3C7529':['shed_door','ON','false'],\n 'E5870A':['shed_door2','ON','true'],\n 'E5870E':['shed_door2','OFF','true'],\n 'D3472E':['shed_pir','ON','false']\n };\n\nvar p = msg.command;\n\n\nif (p in d) {\n msg.topic = \"rf433/\" + d[p][0];\n msg.payload = d[p][1];\n msg.retain = d[p][2];\n msg.qos = 0;\n return [msg,null]\n}\nelse {\n msg.topic = \"RFBridge Signal not regognised\";\n msg.command = p;\n msg.retain = \"false\";\n msg.qos = 0;\n msg.pushtype = \"note\";\n return [null,msg]\n}\n\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":680,"y":200,"wires":[["db7ebc780802857e"],[]]},{"id":"db7ebc780802857e","type":"mqtt out","z":"af5854af057f3aac","name":"Publish","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a621bb5.8358248","x":900,"y":200,"wires":[]},{"id":"01ad266367a7b3ca","type":"mqtt in","z":"af5854af057f3aac","name":"RFBridge1","topic":"tele/RFBridge1/RESULT","qos":"0","datatype":"utf8","broker":"a621bb5.8358248","nl":false,"rap":false,"inputs":0,"x":180,"y":80,"wires":[["df9411b657596615"]]},{"id":"df9411b657596615","type":"json","z":"af5854af057f3aac","name":"","property":"payload","action":"obj","pretty":false,"x":330,"y":120,"wires":[["f4e4f178b3529b2a"]]},{"id":"f4e4f178b3529b2a","type":"function","z":"af5854af057f3aac","name":"Convert1","func":"\nvar command = msg.payload.RfRaw.Data;\nif (typeof msg.payload.RFRaw !== 'undefined') {\n if (msg.payload.RfRaw.Data.length>=6) {\n command = msg.payload.RfRaw.Data.substr(16,6);\n return (msg,null);\n }\n} \nmsg.command = command;\nreturn (null,msg);\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":160,"wires":[["30ee99e846d3ec2b"],[]]},{"id":"90741e45ee3f3e52","type":"function","z":"af5854af057f3aac","name":"Convert2","func":"\n\nvar command = msg.payload.event.command;\nmsg.command = command;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":240,"wires":[["30ee99e846d3ec2b"]]},{"id":"88793c7799f4c982","type":"server","name":"ADD YOUR HOMEASSISTANT CONFIG","version":2,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","credentials":{"host":"","access_token":""}},{"id":"a621bb5.8358248","type":"mqtt-broker","name":"YOUR_MQTT_BROKER","broker":"YOUR_MQTT_BROKER","port":"1883","clientid":"YOUR_CLIENT_ID","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""}]

Apologies if I have missed anything or made an error with posting the code.

Hope you find this useful!