Node-Red-Examples/mqtt-split-messages.js

2 lines
1.5 KiB
JavaScript

[{"id":"bc0635f2.5a2d38","type":"mqtt in","z":"5d993ad1.d0ad14","name":"","topic":"ESP_Sensor1/#","qos":"2","datatype":"auto","broker":"27e18df8.22eae2","x":280,"y":180,"wires":[["e9cba957.77362"]]},{"id":"e9cba957.77362","type":"function","z":"5d993ad1.d0ad14","name":"Split Values","func":"var topic=msg.topic;\n\nif (topic==\"ESP_Sensor1/Sensor1/Temperature\"){\n return [ msg, null, null ]; \n}\n\nif (topic==\"ESP_Sensor1/Sensor1/Pressure\"){\n return [ null , msg, null ]; \n}\n\nif (topic==\"ESP_Sensor1/Sensor1/Humidity\"){\n return [ null, null, msg ]; \n}","outputs":3,"noerr":0,"x":490,"y":180,"wires":[["ae59d700.45338"],["705e1355.bbd74c"],["5bcb1b4c.5df4fc"]]},{"id":"ae59d700.45338","type":"debug","z":"5d993ad1.d0ad14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":140,"wires":[]},{"id":"705e1355.bbd74c","type":"debug","z":"5d993ad1.d0ad14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":180,"wires":[]},{"id":"5bcb1b4c.5df4fc","type":"debug","z":"5d993ad1.d0ad14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":220,"wires":[]},{"id":"27e18df8.22eae2","type":"mqtt-broker","z":"","name":"unixweb","broker":"mqtt.unixweb.de","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]