Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Node RED SOX node examples
[{"id":"d641037b.29bf","type":"websocket-listener","path":"/public/gassentiment","wholemsg":"false"},{"id":"b2e20edd.4d1df","type":"pushbullet-config","name":"PushBullet"},{"id":"496da66e.b69258","type":"wotkit-credentials","nickname":"DataHub","url":"http://hub.urbanopus.net/wotkit/"},{"id":"dd0cde9b.22f32","type":"sox-credentials","nickname":"Sensorizer","bosh":"http://sox.ht.sfc.keio.ac.jp:5280/http-bind/","xmpp":"sox.ht.sfc.keio.ac.jp"},{"id":"57c3f620.a83c08","type":"sox in","name":"","device":"神奈川ガソリン安価ランキング1位","transducer":"price","login":"dd0cde9b.22f32","x":158.0994110107422,"y":84,"z":"e9240feb.16dbf","wires":[["1b9117d3.e46ee8"]]},{"id":"bf10dd9c.40ef2","type":"comment","name":"Sensor Details","info":"http://sensorizer.ht.sfc.keio.ac.jp:8888/status?n=c838934feb10e75a06424c0c963a45ae\n\nCredentials:\n\nsensorizer@sox.ht.sfc.keio.ac.jp\nmiromiro\n","x":80.5,"y":149,"z":"e9240feb.16dbf","wires":[]},{"id":"1b9117d3.e46ee8","type":"function","name":"Extract Price Value","func":"if (msg.payload.name == \"price\") {\n return {payload: {value: msg.payload.sensorData.rawValue}};\n}","outputs":1,"noerr":0,"x":294.0992431640625,"y":153.09091186523438,"z":"e9240feb.16dbf","wires":[["42610a6b.bd9ef4","2a605ef8.d59fa2"]]},{"id":"5acd180b.a532e8","type":"rbe","name":"","func":"deadband","gap":"10%","x":547.0994262695312,"y":143.09091186523438,"z":"e9240feb.16dbf","wires":[["35938a5e.ca6c76"]]},{"id":"42610a6b.bd9ef4","type":"wotkit out","name":"","sensor":"calderonroberto.keiogasprice","login":"496da66e.b69258","x":514.0994262695312,"y":219.09091186523438,"z":"e9240feb.16dbf","wires":[]},{"id":"35938a5e.ca6c76","type":"pushbullet","config":"b2e20edd.4d1df","pushtype":"note","title":"","chan":"","name":"","x":658.0994262695312,"y":50.090911865234375,"z":"e9240feb.16dbf","wires":[]},{"id":"2a605ef8.d59fa2","type":"change","name":"","rules":[{"t":"set","p":"payload","to":"msg.payload.value"}],"action":"","property":"","from":"","to":"","reg":false,"x":446.0994110107422,"y":100.09091186523438,"z":"e9240feb.16dbf","wires":[["5acd180b.a532e8"]]},{"id":"6a4ef58b.95b10c","type":"comment","name":"Using Sensorizer Data + UO Hub","info":"Using Sensorizer in Fred allows:\n\n- Quick analysis (alerts on % change)\n- Using Urban Opus to Visualize","x":145.5,"y":39.090911865234375,"z":"e9240feb.16dbf","wires":[]},{"id":"41a6d88a.be5928","type":"sox out","name":"Gas Vancouver","device":"fredtest42","transducer":"occupancy","login":"dd0cde9b.22f32","x":499.09942626953125,"y":376.0909118652344,"z":"e9240feb.16dbf","wires":[]},{"id":"62e80c86.9d17f4","type":"comment","name":"Web Crawler","info":"Send Data to a Sox Device","x":106.09944152832031,"y":337.0909118652344,"z":"e9240feb.16dbf","wires":[]},{"id":"173bbbff.e8c444","type":"sox in","name":"","device":"神奈川ガソリン安価ランキング1位","transducer":"price","login":"dd0cde9b.22f32","x":177.0994415283203,"y":775.8181762695312,"z":"e9240feb.16dbf","wires":[["2d16e5fb.d2e91a"]]},{"id":"389092a7.c76f6e","type":"sox in","name":"Gas Vancouver","device":"fredtest42","transducer":"occupancy","login":"dd0cde9b.22f32","x":109.09944152832031,"y":891.6363525390625,"z":"e9240feb.16dbf","wires":[["a7fc9211.58037"]]},{"id":"b444808b.4bbb8","type":"inject","name":"Trigger Crawl","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":117.09944152832031,"y":460.6363525390625,"z":"e9240feb.16dbf","wires":[["155da6af.eaa259"]]},{"id":"2d16e5fb.d2e91a","type":"function","name":"Extract Price Value","func":"if (msg.payload.name == \"price\") {\n var keio = msg.payload.sensorData.typedValue;\n context.global.keio = keio;\n var vancouver = context.global.vancouver || 0;\n return {payload: {keio: keio, vancouver: vancouver} };\n}","outputs":1,"noerr":0,"x":364.895751953125,"y":828.888916015625,"z":"e9240feb.16dbf","wires":[["602c0578.9fd3fc"]]},{"id":"a7fc9211.58037","type":"function","name":"Extract Price Value","func":"if (msg.payload.name == \"occupancy\") {\n var vancouver = msg.payload.sensorData.typedValue;\n context.global.vancouver = vancouver;\n var keio = (context.global.keio * context.global.exchangerate)*100;\n\n return {payload: {keio: keio, vancouver: vancouver} };\n}","outputs":1,"noerr":0,"x":364.89573669433594,"y":886.888916015625,"z":"e9240feb.16dbf","wires":[["ef696639.109698"]]},{"id":"ef696639.109698","type":"websocket out","name":"","server":"d641037b.29bf","client":"","x":671.895751953125,"y":862.888916015625,"z":"e9240feb.16dbf","wires":[]},{"id":"5e0d77bf.a1f288","type":"comment","name":"Real-time Aggregation","info":"Changing to Other Formats for Visualization","x":117.5,"y":555.888916015625,"z":"e9240feb.16dbf","wires":[]},{"id":"233cdba3.dcc324","type":"http in","name":"","url":"/public/gas","method":"get","swaggerDoc":"","x":106.89582824707031,"y":620.888916015625,"z":"e9240feb.16dbf","wires":[["a5a80967.5a57f8"]]},{"id":"a5a80967.5a57f8","type":"template","name":"","field":"payload","format":"handlebars","template":"<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <title>FRED-powered app</title>\n <link rel=\"stylesheet\" href=\"http://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css\">\n <script src=\"http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js\"></script>\n <script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js\"></script>\n <script src=\"http://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js\"></script>\n <style>#price{background-color:green; margin:auto; padding:10px;border-radius:10px;font-size:40px;font-weight:bold;color:white;text-align:center;width:350px;}</style>\n</head>\n<body>\n <div id=\"messages\"></div>\n <div id=\"price\">Ratio: 1</div>\n <div id=\"bar-example\"></div>\n \n <script type=\"text/javascript\">\n \nvar chart = Morris.Bar({\n element: 'bar-example',\n data: [\n { y: 'Price', a: 50, b: 50 },\n ],\n xkey: 'y',\n ykeys: ['a','b'],\n labels: ['Keio','Vancouver'],\n resize:true\n});\n \n \n // Open a websocket using FRED.\n var listenSocket = new WebSocket(\"ws://fred.sensetecnic.com/public/calderonroberto/gassentiment\");\n\n listenSocket.onmessage = function (event) {\n data = JSON.parse(event.data);\n \n var newData = [{y: 'Price', a: parseInt(data.keio), b: parseInt(data.vancouver)}]\n chart.setData(newData); // this will redraw the chart\n $(\"#price\").html(\"Ratio: \" + (data.vancouver / data.keio).toFixed(2))\n\n $(\"#messages\").append(\"<div class='msg sentiment' >Last updated: \"+ new Date() +\"</div>\")\n if ($(\"#messages\").children().length > 2 ) { $(\"#messages :first-child\").remove()}\n }\n \n listenSocket.onclose = function(event){\n $(\"#messages\").append(\"<div class='msg server'>Disconnected from server.</div>\");\n }\n \n listenSocket.onopen = function(event){\n $(\"#messages\").append(\"<div class='msg server'>Connected to server.</div>\")\n }\n\n </script>\n \n</body>\n</html>","x":227.89578247070312,"y":677.888916015625,"z":"e9240feb.16dbf","wires":[["27e14725.d81eb8"]]},{"id":"27e14725.d81eb8","type":"http response","name":"","x":341.895751953125,"y":627.888916015625,"z":"e9240feb.16dbf","wires":[]},{"id":"efaed193.10513","type":"comment","name":"Sensor Details","info":"http://hub.urbanopus.net/wotkit/\nhttp://hub.urbanopus.net/wotkit/api/sensors/calderonroberto.keiogasprice\n\nCredentials:\n\ncalderonroberto\naMUSEment2\n","x":629.6666259765625,"y":261.6666259765625,"z":"e9240feb.16dbf","wires":[]},{"id":"155da6af.eaa259","type":"http request","name":"","method":"GET","ret":"txt","url":"http://tomorrowsgaspricetoday.com/gas-prices/?city=123&Vancouver-Gas-Prices","x":222,"y":413,"z":"e9240feb.16dbf","wires":[["b108e442.4ef718"]]},{"id":"b108e442.4ef718","type":"html","name":"","tag":"#gas-info-span","ret":"html","as":"multi","x":328,"y":456,"z":"e9240feb.16dbf","wires":[["41a6d88a.be5928","e41b8120.1be48"]]},{"id":"602c0578.9fd3fc","type":"http request","name":"","method":"GET","ret":"txt","url":"https://www.google.ca/finance?q=JPYCAD","x":478,"y":778,"z":"e9240feb.16dbf","wires":[["788e45b1.8771bc"]]},{"id":"788e45b1.8771bc","type":"html","name":"","tag":"span.bld","ret":"html","as":"single","x":510,"y":741,"z":"e9240feb.16dbf","wires":[["dac32f62.253cd"]]},{"id":"dac32f62.253cd","type":"function","name":"Adjust for Rate","func":"var exchangerate = msg.payload[0].split(' ')[0];\ncontext.global.exchangerate = exchangerate;\n\nvar keio = (context.global.keio * context.global.exchangerate)* 100;\nvar vancouver = context.global.vancouver || 0;\nreturn {payload: {keio: keio, vancouver: vancouver} };\n\n","outputs":1,"noerr":0,"x":625,"y":696,"z":"e9240feb.16dbf","wires":[["ef696639.109698"]]},{"id":"e41b8120.1be48","type":"debug","name":"","active":false,"console":"false","complete":"false","x":513,"y":467,"z":"e9240feb.16dbf","wires":[]},{"id":"749b38e7.8b64c8","type":"inject","name":"Inject \"50\"","topic":"","payload":"500","payloadType":"string","repeat":"","crontab":"","once":false,"x":331,"y":318,"z":"e9240feb.16dbf","wires":[["41a6d88a.be5928"]]},{"id":"6db1d28e.924e2c","type":"freeboard","name":"Dashboard Freeboard","x":511,"y":1231,"z":"e9240feb.16dbf","wires":[]},{"id":"9687bde0.69784","type":"wotkit data","name":"","before":"1","beforeType":"elements","sensor":"mike.yvr-depart ","login":"496da66e.b69258","x":303,"y":1178,"z":"e9240feb.16dbf","wires":[["6db1d28e.924e2c"]]},{"id":"b62f57a6.49d0a8","type":"inject","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":126,"y":1232,"z":"e9240feb.16dbf","wires":[["9687bde0.69784"]]},{"id":"4b9bbe32.b4644","type":"sox in","name":"Gas Vancouver","device":"fredtest42","transducer":"occupancy","login":"dd0cde9b.22f32","x":299,"y":1287,"z":"e9240feb.16dbf","wires":[["6db1d28e.924e2c"]]},{"id":"10b953f3.ef46ac","type":"debug","name":"","active":true,"console":"false","complete":"false","x":420,"y":1099,"z":"e9240feb.16dbf","wires":[]},{"id":"da4b89f5.25b478","type":"sox in","name":"","device":"神奈川ガソリン安価ランキング1位","transducer":"price","login":"dd0cde9b.22f32","x":244,"y":1040,"z":"e9240feb.16dbf","wires":[["10b953f3.ef46ac"]]},{"id":"52d394d8.ad2c6c","type":"comment","name":"Dashboards","info":"","x":121,"y":1134,"z":"e9240feb.16dbf","wires":[]},{"id":"84b8da6a.7b4728","type":"comment","name":"Simple example.","info":"","x":144,"y":982,"z":"e9240feb.16dbf","wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.