osd-contiki/examples/zolertia/zoul/node-red/mqtt-remote-demo.json

3 lines
3.2 KiB
JSON

[{"id":"d95a1e7f.43a","type":"mqtt-broker","broker":"localhost","port":"1883","clientid":""},{"id":"ddd5cc1c.723e18","type":"mqtt in","name":"MQTT input from Re-Mote","topic":"iot-2/evt/status/fmt/json","broker":"d95a1e7f.43a","x":131.11109924316406,"y":98.88890075683594,"z":"9b2868a4.2cef5","wires":[["12ea094e.3c2447"]]},{"id":"7728d120.25c64","type":"function","name":"Parse and Store Data","func":"var dat = msg.payload.d;\n\nif(dat) {\n var ret = [\n {\n name: \"Name\",\n value: dat.myName,\n unit: \"\",\n },\n {\n name: \"Seq #\",\n value: dat[\"Seq #\"],\n unit: \"\",\n },\n {\n name: \"Uptime\",\n value: dat[\"Uptime (sec)\"],\n unit: \"sec\",\n },\n {\n name: \"On-Chip Temp\",\n value: dat[\"On-Chip Temp (mC)\"],\n unit: \"C\",\n },\n {\n name: \"VDD/3\",\n value: dat[\"VDD3 (mV)\"],\n unit: \"V\",\n },\n {\n name: \"Parent RSSI\",\n value: dat[\"RSSI (dBm)\"],\n unit: \"dBm\",\n },\n ];\n \n context.ret = ret;\n} else {\n if(context.ret) {\n msg.has_data = true;\n msg.payload = context.ret;\n } else {\n msg.payload = \"No Data!\";\n }\n return [msg, msg];\n}\nreturn [msg, null];","outputs":"2","x":545.1110992431641,"y":346.38890075683594,"z":"9b2868a4.2cef5","wires":[["4249c5c.35b5c3c"],["dacab617.9133c8"]]},{"id":"12ea094e.3c2447","type":"json","name":"Convert to JS Object","x":305.61109924316406,"y":263.13890075683594,"z":"9b2868a4.2cef5","wires":[["7728d120.25c64"]]},{"id":"e5e8271c.99c2d","type":"http response","name":"Send HTTP Reponse","x":1252.2220611572266,"y":488.38890075683594,"z":"9b2868a4.2cef5","wires":[]},{"id":"4b2260f8.436808","type":"http in","name":"","url":"/remote","method":"get","x":327.11109924316406,"y":429.88890075683594,"z":"9b2868a4.2cef5","wires":[["8a3f88a9.ec77d8","7728d120.25c64"]]},{"id":"8a3f88a9.ec77d8","type":"debug","name":"","active":false,"console":"false","complete":"req","x":459.61109924316406,"y":522.3889007568359,"z":"9b2868a4.2cef5","wires":[]},{"id":"ac349e33.beb47","type":"template","name":"Render HTML from Data","field":"payload","template":"<html>\n<body>\n<ul>\n {{#payload}}\n <li>{{name}}: {{value}}{{#unit}} {{unit}}{{/unit}}</li>\n {{/payload}}\n</ul>\n</body>\n</html>","x":1046.361099243164,"y":347.13890075683594,"z":"9b2868a4.2cef5","wires":[["e5e8271c.99c2d","530bf522.d773dc"]]},{"id":"4249c5c.35b5c3c","type":"debug","name":"","active":false,"console":"false","complete":"false","x":620.1110992431641,"y":247.88890075683594,"z":"9b2868a4.2cef5","wires":[]},{"id":"dacab617.9133c8","type":"switch","name":"","property":"has_data","rules":[{"t":"true"},{"t":"else"}],"checkall":"false","outputs":2,"x":765.1110992431641,"y":352.88890075683594,"z":"9b2868a4.2cef5","wires":[["124554c4.5b82b3","ac349e33.beb47"],["e5e8271c.99c2d"]]},{"id":"530bf522.d773dc","type":"debug","name":"","active":false,"console":"false","complete":"payload","x":1228.361099243164,"y":217.88890075683594,"z":"9b2868a4.2cef5","wires":[]},{"id":"124554c4.5b82b3","type":"debug","name":"","active":false,"console":"false","complete":"payload","x":898.1110992431641,"y":220.88890075683594,"z":"9b2868a4.2cef5","wires":[]}]