Two Sensors (Scale HX477 & RFID RC522) changed payload

Hello,
I'm in the beginning with node-red. A amateur...
I use it with a MQTT Broker on a RASPI and i switch a lot aof SONOFF Devices with Tasmota.
All working nice.
Now i will start with a small new Project on a ESP8266.
I have there a Scale HX477, Temp/HUMI AM2301 and a RFID RC522 Sensor.
All tree Sensors are Working by himself.
They running with a Tasmota on the back.

Now my Problem:
The Scale and the Temp/Humi Sensor comes together in a Payload. I changed %topic%/%prefix%/, i think it a nicer looking in a MQTT Explorer.
ScaleRFID/tele/SENSOR
The Values are changing after some seconds.
If i have something on the scale, i see weight, temp and humidity.
When i put a RFID Tag on my RC522 Reader, the weight, temp and humidity are LOST.


But i will write the DATAS complete together in a CSV Excel Sheet.
WEIGHT and UID, Data and Type (maybe)

But everytime i have this fault on the debug and I'm shure that comes from my two different payloads.
I have NO IDEA how can i fix that, that i have a COMPLETE String with all together or i put it sepaerate together.

Best regards and THANK YOU for some Tips and Ideas to find my fault.

[{"id":"8c96dc4d.c86e48","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"30c0bd7.e8def42","type":"mqtt in","z":"8c96dc4d.c86e48","name":"","topic":"ScaleRFID/tele/SENSOR","qos":"0","datatype":"auto","broker":"816bdf3a.224ba","x":190,"y":40,"wires":[["41f1a0ef.ccf4a"]]},{"id":"4eb97d0b.f2aaec","type":"ui_gauge","z":"8c96dc4d.c86e48","name":"Temperature","group":"daeda5a2.95e42","order":1,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"","format":"{{msg.payload.AM2301.Temperature|number:1}} °C","min":"-20","max":"50","colors":["#0012b5","#e6e600","#ff0000"],"seg1":"","seg2":"","x":770,"y":40,"wires":[]},{"id":"41f1a0ef.ccf4a","type":"json","z":"8c96dc4d.c86e48","name":"","property":"payload","action":"","pretty":false,"x":410,"y":40,"wires":[["6aac0e86.9d2bb8","b6769951.242288","e1b52716.7381e8","4eb97d0b.f2aaec","5cc86b8e.32f434","a0c60690.0af66","82430fa2.b6b648"]]},{"id":"6aac0e86.9d2bb8","type":"ui_gauge","z":"8c96dc4d.c86e48","name":"Humidity","group":"daeda5a2.95e42","order":2,"width":0,"height":0,"gtype":"gage","title":"Humidity","label":"%","format":"{{msg.payload.AM2301.Humidity}} %","min":"0","max":"100","colors":["#ff0000","#e6e600","#0000ff"],"seg1":"","seg2":"","x":760,"y":100,"wires":[]},{"id":"e1b52716.7381e8","type":"ui_gauge","z":"8c96dc4d.c86e48","name":"Weight","group":"f1821797.664718","order":3,"width":0,"height":0,"gtype":"gage","title":"Weight","label":"Kilogramm","format":"{{msg.payload.HX711.Weight|number:3}} kg","min":"-0.5","max":"5.000","colors":["#00ffff","#00ff00","#ff0000"],"seg1":"0","seg2":"","x":750,"y":220,"wires":[]},{"id":"b6769951.242288","type":"ui_text","z":"8c96dc4d.c86e48","group":"f1821797.664718","order":4,"width":6,"height":2,"name":"Weight","label":"Weight","format":"{{msg.payload.HX711.Weight}} kg","layout":"row-spread","x":750,"y":160,"wires":[]},{"id":"ffea5ac7.3e3d2","type":"ui_text","z":"8c96dc4d.c86e48","group":"c4276039.d2921","order":3,"width":0,"height":0,"name":"UID","label":"UID","format":"{{msg.payload.RC522.UID}}","layout":"row-spread","x":750,"y":280,"wires":[]},{"id":"c0fa1252.5f48","type":"ui_text","z":"8c96dc4d.c86e48","group":"c4276039.d2921","order":5,"width":0,"height":0,"name":"Data","label":"Data","format":"{{msg.payload.RC522.Data}}","layout":"row-spread","x":750,"y":340,"wires":[]},{"id":"dae938c9.e7ba18","type":"ui_text","z":"8c96dc4d.c86e48","group":"c4276039.d2921","order":7,"width":0,"height":0,"name":"Type","label":"Type","format":"{{msg.payload.RC522.Type}}","layout":"row-spread","x":750,"y":400,"wires":[]},{"id":"43be6e18.a5514","type":"json","z":"8c96dc4d.c86e48","name":"","property":"payload","action":"","pretty":false,"x":410,"y":480,"wires":[["ffea5ac7.3e3d2","c0fa1252.5f48","dae938c9.e7ba18","8b93bf09.3b6cb","692dbf81.b7c968","c327e8b3.239248","e74c00a7.3919f8","69df02a4.0a7074"]]},{"id":"8b93bf09.3b6cb","type":"switch","z":"8c96dc4d.c86e48","name":"RFID Tags","property":"payload.RC522.UID","propertyType":"msg","rules":[{"t":"eq","v":"ABCD1234","vt":"str"},{"t":"eq","v":"A1B2C3D4","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":750,"y":540,"wires":[["54420c90.3fffdc"],["4cafa792.4f72a"],["adfbde23.fa179"]]},{"id":"54420c90.3fffdc","type":"function","z":"8c96dc4d.c86e48","name":"msg.payload = \"granted\";","func":"msg.payload = \"granted\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1050,"y":660,"wires":[["1e40924b.d4933e","c8aedb5d.b36fb8"]]},{"id":"4cafa792.4f72a","type":"function","z":"8c96dc4d.c86e48","name":"msg.payload = \"denied\";","func":"msg.payload = \"denied\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1050,"y":740,"wires":[["1e40924b.d4933e","c8aedb5d.b36fb8"]]},{"id":"1e40924b.d4933e","type":"ui_toast","z":"8c96dc4d.c86e48","position":"bottom right","displayTime":"","highlight":"","sendall":true,"outputs":0,"ok":"","cancel":"","raw":false,"topic":"","name":"RFID","x":1330,"y":660,"wires":[]},{"id":"c8aedb5d.b36fb8","type":"ui_led","z":"8c96dc4d.c86e48","group":"c4276039.d2921","order":1,"width":0,"height":0,"label":"Status","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"red","value":"denied","valueType":"str"},{"color":"green","value":"granted","valueType":"str"},{"color":"yellow","value":"unknown","valueType":"str"}],"allowColorForValueInMessage":false,"name":"Status","x":1330,"y":740,"wires":[]},{"id":"8fd4a010.13938","type":"inject","z":"8c96dc4d.c86e48","name":"granted green","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"granted\"","payloadType":"json","x":750,"y":660,"wires":[["54420c90.3fffdc"]]},{"id":"34eccb98.6578ec","type":"inject","z":"8c96dc4d.c86e48","name":"denied red","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"denied\"","payloadType":"json","x":740,"y":740,"wires":[["4cafa792.4f72a"]]},{"id":"adfbde23.fa179","type":"function","z":"8c96dc4d.c86e48","name":"msg.payload = \"unknown\";","func":"msg.payload = \"unknown\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1060,"y":820,"wires":[["c8aedb5d.b36fb8","1e40924b.d4933e"]]},{"id":"4ac78cb4.8282ac","type":"inject","z":"8c96dc4d.c86e48","name":"unknown yellow","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"unknown\"","payloadType":"json","x":760,"y":820,"wires":[["adfbde23.fa179"]]},{"id":"a32b3721.7c8718","type":"file","z":"8c96dc4d.c86e48","name":"","filename":"/home/pi/.node-red/persist/ScaleRFID.csv","appendNewline":true,"createDir":false,"overwriteFile":"false","encoding":"none","x":1560,"y":480,"wires":[[]]},{"id":"de343449.742a2","type":"debug","z":"8c96dc4d.c86e48","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1470,"y":440,"wires":[]},{"id":"692dbf81.b7c968","type":"function","z":"8c96dc4d.c86e48","name":"","func":"//var Weight = msg.payload.HX711.Weight;\nvar Weight = 1.234;\n\n\nWeight_Komma = (String(Weight));\nWeight_Komma = Weight_Komma.replace('.', ',');\n\nvar UID = msg.payload.RC522.UID;\nvar Data = msg.payload.RC522.Data;\nvar Type = msg.payload.RC522.Type;\n\nvar CSV_Datei = UID + \";\" + Data + \";\" + Type + \";\" + Weight_Komma;\n\nreturn {payload: CSV_Datei};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1180,"y":480,"wires":[["a32b3721.7c8718","de343449.742a2"]]},{"id":"292a3478.4eecd4","type":"comment","z":"8c96dc4d.c86e48","name":"Test LED YES, NO, UNKNOWN","info":"","x":650,"y":620,"wires":[]},{"id":"19801e4c.090832","type":"comment","z":"8c96dc4d.c86e48","name":"Erzeugen einer CSV Daten werden Zeilenweise eingetragen","info":"","x":1340,"y":520,"wires":[]},{"id":"e921cb8e.b9833","type":"mqtt in","z":"8c96dc4d.c86e48","name":"","topic":"ScaleRFID/tele/SENSOR","qos":"0","datatype":"auto","broker":"816bdf3a.224ba","x":190,"y":480,"wires":[["43be6e18.a5514"]]},{"id":"c327e8b3.239248","type":"debug","z":"8c96dc4d.c86e48","name":"payload.RC522.UID","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload.RC522.UID","targetType":"msg","statusVal":"payload.RC522.UID","statusType":"auto","x":1000,"y":280,"wires":[]},{"id":"e74c00a7.3919f8","type":"debug","z":"8c96dc4d.c86e48","name":"payload.RC522.Data","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload.RC522.Data","targetType":"msg","statusVal":"payload.RC522.UID","statusType":"auto","x":1000,"y":340,"wires":[]},{"id":"69df02a4.0a7074","type":"debug","z":"8c96dc4d.c86e48","name":"payload.RC522.Type","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload.RC522.Type","targetType":"msg","statusVal":"payload.RC522.UID","statusType":"auto","x":1000,"y":400,"wires":[]},{"id":"5cc86b8e.32f434","type":"debug","z":"8c96dc4d.c86e48","name":"payload.AM2301.Temperature","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload.AM2301.Temperature","targetType":"msg","statusVal":"payload.RC522.UID","statusType":"auto","x":1030,"y":40,"wires":[]},{"id":"a0c60690.0af66","type":"debug","z":"8c96dc4d.c86e48","name":"payload.AM2301.Humidity","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload.AM2301.Humidity","targetType":"msg","statusVal":"payload.RC522.UID","statusType":"auto","x":1010,"y":100,"wires":[]},{"id":"82430fa2.b6b648","type":"debug","z":"8c96dc4d.c86e48","name":"payload.HX711.Weight","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload.HX711.Weight","targetType":"msg","statusVal":"payload.RC522.UID","statusType":"auto","x":1000,"y":160,"wires":[]},{"id":"816bdf3a.224ba","type":"mqtt-broker","name":"RASPI","broker":"raspi","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"daeda5a2.95e42","type":"ui_group","name":"Scale","tab":"f63a690d.6cb528","order":1,"disp":true,"width":5,"collapse":false},{"id":"f1821797.664718","type":"ui_group","name":"Messwerte HX711","tab":"f63a690d.6cb528","order":2,"disp":true,"width":6,"collapse":false},{"id":"c4276039.d2921","type":"ui_group","name":"RFID","tab":"f63a690d.6cb528","order":4,"disp":true,"width":5,"collapse":false},{"id":"f63a690d.6cb528","type":"ui_tab","name":"ScaleRFID","icon":"dashboard","order":17,"disabled":false,"hidden":false}]

Last Picture with the function

This is not really a fault of node-red.

You can "work around it" by putting a switch node after the MQTT node to detect when RC522 is present and direct the flow in another route.

2ndly, It is better to not have 2 MQTT IN nodes with the same topic twice, you will likely get 2 messages per MQTT in.

image

Ohhh... that is easy.
Thank you very much !