node-red-m2x
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -1,1 +0,2 @@ | ||
[{"type":"tab","id":"d8a3e781.275c18","label":"Sheet 1"},{"id":"704442f7.8fbbbc","type":"m2x feed","apiKey":"3cf3bb243e288dcb343ddd65dd1b5302","name":"My M2x node"},{"id":"ceb4b7d1.314b48","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":1324.0000305175781,"y":257,"z":"d8a3e781.275c18","wires":[["2d3546eb.d2caba","dc56a763.23a958"]]},{"id":"be6c5781.4193a8","type":"function","name":"Create Trigger for > 200 Degrees","func":"msg.topic = \"devices\";\n\nmsg.action = \"createTrigger\";\n\nmsg.topic_id = \"1b2f98cc3b31b527c27ba14fe46c615c\";\n\nmsg.payload = { \"stream\": \"temperature\", \n\n \"name\": \"high temp\", \n\n \"condition\": \">\", \n\n \"value\": 200, \n\n \"callback_url\": \"http://localhost:1880/high\", \n\n \"status\": \"enabled\", \n\n \"send_location\": true }; \nreturn msg;","outputs":1,"x":1088.0001525878906,"y":258,"z":"d8a3e781.275c18","wires":[["ceb4b7d1.314b48"]]},{"id":"6d5fb737.92a048","type":"http request","name":"> 200 ","method":"GET","url":"/hot","x":100,"y":565.0000305175781,"z":"d8a3e781.275c18","wires":[["4daf277b.b250d8"]]},{"id":"2d3546eb.d2caba","type":"debug","name":"","active":true,"console":"true","complete":"false","x":1425.0000915527344,"y":189,"z":"d8a3e781.275c18","wires":[]},{"id":"4966ba86.b69944","type":"function","name":"Delete Trigger for > 200 Degrees if exists","func":"console.log(msg.payload);\n\nmsg.topic = \"devices\";\nmsg.action = \"deleteTrigger\";\nmsg.topic_id = \"1b2f98cc3b31b527c27ba14fe46c615c\";\nmsg.sub_topic_id = msg.payload;\nmsg.payload = {};\nreturn msg;","outputs":1,"x":1068.0000305175781,"y":120,"z":"d8a3e781.275c18","wires":[["4ddcb92a.b22348"]]},{"id":"e969d087.16963","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":473,"y":192,"z":"d8a3e781.275c18","wires":[["2a706e23.d58f92"]]},{"id":"37b9ce.ffc84632","type":"function","name":"Get All Triggers","func":"msg.topic = \"devices\";\nmsg.action = \"triggers\";\nmsg.topic_id = \"1b2f98cc3b31b527c27ba14fe46c615c\";\nmsg.payload = {};\nreturn msg;","outputs":1,"x":301,"y":194,"z":"d8a3e781.275c18","wires":[["e969d087.16963"]]},{"id":"2a706e23.d58f92","type":"function","name":"Find the if high tempe trigger exists","func":"if (!msg.payload) {\n\tconsole.log(\"No Payload quit flow\");\n\tmsg.payload = -1;\n} else {\n\tif (!msg.payload.triggers) {\n\t\tconsole.log(\"No Triggers found\");\n\t\tmsg.payload = -1;\n\t} \n\telse \n\t{\n\t\tvar triggers = msg.payload.triggers;\n\t\tfor(var trigger in msg.payload.triggers) {\n\t\t console.log(triggers[trigger].name);\n\t\t\tif (typeof (triggers[trigger].name) === 'string' && triggers[trigger].name === \"high temp\") {\t\t\t\t\n\t\t\tconsole.log(\"High temp Trigger found \"+ triggers[trigger].id);\n\t\t\tmsg.payload = triggers[trigger].id;\t\n\t\t\treturn msg;\n\t\t\t} \n\t\t}\n\t}\n}\nmsg.payload = -1;\nconsole.log(\"Counldn't find high temp trigger, go directly to create it\");\nreturn msg;","outputs":"1","x":687.0000305175781,"y":190,"z":"d8a3e781.275c18","wires":[["81deccc4.7e213"]]},{"id":"81deccc4.7e213","type":"switch","name":"","property":"payload","rules":[{"t":"neq","v":-1,"v2":0},{"t":"else"}],"checkall":"true","outputs":2,"x":915.0001525878906,"y":194,"z":"d8a3e781.275c18","wires":[["4966ba86.b69944"],["be6c5781.4193a8"]]},{"id":"4ddcb92a.b22348","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":1327.0000305175781,"y":119,"z":"d8a3e781.275c18","wires":[["be6c5781.4193a8"]]},{"id":"d0cbca4d.2f3438","type":"function","name":"Create relevant Out Message","func":"msg.topic=\"charts\";\nmsg.action=\"render\";\nmsg.topic_id=\"f149a94a715fa12455c9ad53f7b18e42\";\nmsg.sub_topic_id=\"svg\";\nreturn msg;","outputs":1,"x":310,"y":743.0000915527344,"z":"d8a3e781.275c18","wires":[["8b7e8fbf.74817"]]},{"id":"8b7e8fbf.74817","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":542.0000305175781,"y":744.0000915527344,"z":"d8a3e781.275c18","wires":[["6fc363d1.903c9c"]]},{"id":"6fc363d1.903c9c","type":"function","name":"Extract Graph Data","func":"msg.payload = msg.payload.raw;\n\nreturn msg;","outputs":1,"x":718.0000305175781,"y":749.0001525878906,"z":"d8a3e781.275c18","wires":[["2c3fc26c.d3c03e"]]},{"id":"2c3fc26c.d3c03e","type":"template","name":"Create the HTML","field":"payload","template":"<html>\n<head/>\n<body>\n<img src=\"data:image/svg+xml;,{{payload}}\" hieght=\"600\" width=\"800\"/>\n</body>\n</html","x":897.0000305175781,"y":748.0000915527344,"z":"d8a3e781.275c18","wires":[["2c51ec4d.d3ae14"]]},{"id":"dc388f81.23c77","type":"http in","name":"","url":"/graph","method":"get","x":95,"y":743.0000305175781,"z":"d8a3e781.275c18","wires":[["d0cbca4d.2f3438"]]},{"id":"2c51ec4d.d3ae14","type":"http response","name":"","x":1072.0002746582031,"y":752.0002746582031,"z":"d8a3e781.275c18","wires":[]},{"id":"d7396ed3.28c69","type":"comment","name":"Display Stream Graph","info":"","x":152.88888549804688,"y":667.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"271fafa5.d8e05","type":"inject","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":110.88888549804688,"y":435.8888854980469,"z":"d8a3e781.275c18","wires":[["84881931.7b77e8"]]},{"id":"84881931.7b77e8","type":"function","name":"Inject Random Temperature between 195 and 204","func":"var temp = Math.random()*10+ 195;\nmsg.topic = \"devices\";\nmsg.action = \"setStreamValue\";\nmsg.topic_id = \"1b2f98cc3b31b527c27ba14fe46c615c\";\nmsg.sub_topic_id = \"temperature\";\nmsg.payload = { \"at\": new Date().toJSON(), \"value\": temp}\nreturn msg;","outputs":1,"x":424.8888854980469,"y":434.8888854980469,"z":"d8a3e781.275c18","wires":[["2d33482e.d2ccb8"]]},{"id":"2d33482e.d2ccb8","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":747.8889465332031,"y":436.8888854980469,"z":"d8a3e781.275c18","wires":[["51afa1eb.ae506"]]},{"id":"51afa1eb.ae506","type":"debug","name":"","active":false,"console":"false","complete":"false","x":952.8889465332031,"y":410.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"c363ddcc.3c9c2","type":"comment","name":"Create Trigger for 200 degrees erase the previous one if exists first","info":"","x":255.88888549804688,"y":59.888885498046875,"z":"d8a3e781.275c18","wires":[]},{"id":"1a42bf38.e5bd41","type":"comment","name":"Inject temperature reading every 10 seconds","info":"","x":212.88888549804688,"y":331.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"8a1d6b15.75e298","type":"debug","name":"","active":true,"console":"false","complete":"false","x":468.8888854980469,"y":560.8889465332031,"z":"d8a3e781.275c18","wires":[]},{"id":"4daf277b.b250d8","type":"function","name":"Write log Message","func":"msg.payload = \"200 Limit was reached - \"+ msg.value + \" was recorded.\"\nreturn msg;","outputs":1,"x":278.8888854980469,"y":569.8888854980469,"z":"d8a3e781.275c18","wires":[["8a1d6b15.75e298"]]},{"id":"3e6d0518.c192fa","type":"comment","name":"Trigger critiria was met","info":"","x":127.88888549804688,"y":508.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"bb93efe4.446c1","type":"http in","name":"","url":"/create_trigger","method":"get","x":109.88888549804688,"y":195.88888549804688,"z":"d8a3e781.275c18","wires":[["37b9ce.ffc84632"]]},{"id":"dc56a763.23a958","type":"http response","name":"","x":1487.8889465332031,"y":258.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"d74083f6.28bf8","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":1387.8890686035156,"y":984.8889541625977,"z":"d8a3e781.275c18","wires":[["65891d8e.9a76e4","2d0a145.fd2f5ec"]]},{"id":"383105a6.c7cefa","type":"function","name":"Create m2x_node_red_distrib distribution","func":"msg.topic = \"distributions\";\nmsg.action = \"create\";\nmsg.payload = { \"name\" : \"m2x_node_red_distrib\",\"description\" : \"m2x ndoe red testing\", \"visibility\" : \"private\", \"base_device\" : \"1b2f98cc3b31b527c27ba14fe46c615c\"};\nreturn msg;","outputs":1,"x":1144.8890075683594,"y":989.8889350891113,"z":"d8a3e781.275c18","wires":[["d74083f6.28bf8"]]},{"id":"65891d8e.9a76e4","type":"debug","name":"","active":true,"console":"false","complete":"false","x":1567.8890686035156,"y":905.8889713287354,"z":"d8a3e781.275c18","wires":[]},{"id":"ddaeac57.22515","type":"comment","name":"Create m2x_node_red distribution and erase the previous one if exists first","info":"","x":310.8888854980469,"y":820.4444885253906,"z":"d8a3e781.275c18","wires":[]},{"id":"1a7ec325.e5813d","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":515.8889465332031,"y":904.6667060852051,"z":"d8a3e781.275c18","wires":[["45780a19.ba87f4"]]},{"id":"13213b64.ecdec5","type":"function","name":"Get All Distribution","func":"msg.topic = \"distributions\";\nmsg.action = \"list\";\nmsg.payload = {};\nreturn msg;","outputs":1,"x":326.8888854980469,"y":900.6667060852051,"z":"d8a3e781.275c18","wires":[["1a7ec325.e5813d"]]},{"id":"45780a19.ba87f4","type":"function","name":"Find the if m2x_node_red_distrib exists","func":"if (!msg.payload) {\n\tconsole.log(\"No Payload quit flow\");\n\tmsg.payload = -1;\n} else {\n\tif (!msg.payload.distributions) {\n\t\tconsole.log(\"No distributions found\");\n\t\tmsg.payload = -1;\n\t} \n\telse \n\t{\n\t\tvar distribs = msg.payload.distributions;\n\t\tfor(var distrib in distribs) {\n\t\t console.log(distribs[distrib].name);\n\t\t\tif (typeof (distribs[distrib].name) === 'string' && distribs[distrib].name === \"m2x_node_red_distrib\") {\t\t\t\t\n\t\t\tconsole.log(\"Distribution m2x_node_red_distrib found \"+ distribs[distrib].id);\n\t\t\tmsg.payload = distribs[distrib].id;\t\n\t\t\treturn msg;\n\t\t\t} \n\t\t}\n\t}\n}\nmsg.payload = -1;\nconsole.log(\"Counldn't find m2x_node_red_distrib distribution, go directly to create it\");\nreturn msg;","outputs":"1","x":778.8889465332031,"y":901.6667060852051,"z":"d8a3e781.275c18","wires":[["aed355c2.512ca8"]]},{"id":"aed355c2.512ca8","type":"switch","name":"","property":"payload","rules":[{"t":"neq","v":-1,"v2":0},{"t":"else"}],"checkall":"true","outputs":2,"x":1021.8890686035156,"y":904.6667175292969,"z":"d8a3e781.275c18","wires":[["332c2e44.ccd3d2"],["383105a6.c7cefa"]]},{"id":"e3c65244.1c39b","type":"http in","name":"","url":"/create_distribution","method":"get","x":109.77777099609375,"y":902.5555725097656,"z":"d8a3e781.275c18","wires":[["13213b64.ecdec5"]]},{"id":"332c2e44.ccd3d2","type":"function","name":"Delete m2x_node_red_distribution if exists","func":"console.log(msg.payload);\n\nmsg.topic = \"distributions\";\nmsg.action = \"deleteDistribution\";\nmsg.topic_id = msg.payload;\nmsg.payload = {};\nreturn msg;","outputs":1,"x":1186.8889465332031,"y":825.8889465332031,"z":"d8a3e781.275c18","wires":[["4392684c.bc6d98"]]},{"id":"4392684c.bc6d98","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":1449.888916015625,"y":826.888916015625,"z":"d8a3e781.275c18","wires":[["383105a6.c7cefa"]]},{"id":"2d0a145.fd2f5ec","type":"http response","name":"","x":1581.888916015625,"y":984.7777709960938,"z":"d8a3e781.275c18","wires":[]}] | ||
<<<<<<< HEAD | ||
[{"type":"tab","id":"d8a3e781.275c18","label":"Sheet 1"},{"id":"704442f7.8fbbbc","type":"m2x feed","apiKey":"YOUR ACCOUNT KEY HERE","name":"My M2x node"},{"id":"ceb4b7d1.314b48","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":1324.0000305175781,"y":257,"z":"d8a3e781.275c18","wires":[["2d3546eb.d2caba","dc56a763.23a958"]]},{"id":"be6c5781.4193a8","type":"function","name":"Create Trigger for > 200 Degrees","func":"msg.topic = \"devices\";\n\nmsg.action = \"createTrigger\";\n\nmsg.topic_id = \"1b2f98cc3b31b527c27ba14fe46c615c\";\n\nmsg.payload = { \"stream\": \"temperature\", \n\n \"name\": \"high temp\", \n\n \"condition\": \">\", \n\n \"value\": 200, \n\n \"callback_url\": \"http://localhost:1880/high\", \n\n \"status\": \"enabled\", \n\n \"send_location\": true }; \nreturn msg;","outputs":1,"x":1088.0001525878906,"y":258,"z":"d8a3e781.275c18","wires":[["ceb4b7d1.314b48"]]},{"id":"6d5fb737.92a048","type":"http request","name":"> 200 ","method":"GET","url":"/hot","x":100,"y":565.0000305175781,"z":"d8a3e781.275c18","wires":[["4daf277b.b250d8"]]},{"id":"2d3546eb.d2caba","type":"debug","name":"","active":true,"console":"true","complete":"false","x":1425.0000915527344,"y":189,"z":"d8a3e781.275c18","wires":[]},{"id":"4966ba86.b69944","type":"function","name":"Delete Trigger for > 200 Degrees if exists","func":"console.log(msg.payload);\n\nmsg.topic = \"devices\";\nmsg.action = \"deleteTrigger\";\nmsg.topic_id = \"1b2f98cc3b31b527c27ba14fe46c615c\";\nmsg.sub_topic_id = msg.payload;\nmsg.payload = {};\nreturn msg;","outputs":1,"x":1068.0000305175781,"y":120,"z":"d8a3e781.275c18","wires":[["4ddcb92a.b22348"]]},{"id":"e969d087.16963","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":473,"y":192,"z":"d8a3e781.275c18","wires":[["2a706e23.d58f92"]]},{"id":"37b9ce.ffc84632","type":"function","name":"Get All Triggers","func":"msg.topic = \"devices\";\nmsg.action = \"triggers\";\nmsg.topic_id = \"1b2f98cc3b31b527c27ba14fe46c615c\";\nmsg.payload = {};\nreturn msg;","outputs":1,"x":301,"y":194,"z":"d8a3e781.275c18","wires":[["e969d087.16963"]]},{"id":"2a706e23.d58f92","type":"function","name":"Find the if high tempe trigger exists","func":"if (!msg.payload) {\n\tconsole.log(\"No Payload quit flow\");\n\tmsg.payload = -1;\n} else {\n\tif (!msg.payload.triggers) {\n\t\tconsole.log(\"No Triggers found\");\n\t\tmsg.payload = -1;\n\t} \n\telse \n\t{\n\t\tvar triggers = msg.payload.triggers;\n\t\tfor(var trigger in msg.payload.triggers) {\n\t\t console.log(triggers[trigger].name);\n\t\t\tif (typeof (triggers[trigger].name) === 'string' && triggers[trigger].name === \"high temp\") {\t\t\t\t\n\t\t\tconsole.log(\"High temp Trigger found \"+ triggers[trigger].id);\n\t\t\tmsg.payload = triggers[trigger].id;\t\n\t\t\treturn msg;\n\t\t\t} \n\t\t}\n\t}\n}\nmsg.payload = -1;\nconsole.log(\"Counldn't find high temp trigger, go directly to create it\");\nreturn msg;","outputs":"1","x":687.0000305175781,"y":190,"z":"d8a3e781.275c18","wires":[["81deccc4.7e213"]]},{"id":"81deccc4.7e213","type":"switch","name":"","property":"payload","rules":[{"t":"neq","v":-1,"v2":0},{"t":"else"}],"checkall":"true","outputs":2,"x":915.0001525878906,"y":194,"z":"d8a3e781.275c18","wires":[["4966ba86.b69944"],["be6c5781.4193a8"]]},{"id":"4ddcb92a.b22348","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":1327.0000305175781,"y":119,"z":"d8a3e781.275c18","wires":[["be6c5781.4193a8"]]},{"id":"d0cbca4d.2f3438","type":"function","name":"Create relevant Out Message","func":"msg.topic=\"charts\";\nmsg.action=\"render\";\nmsg.topic_id=\"f149a94a715fa12455c9ad53f7b18e42\";\nmsg.sub_topic_id=\"svg\";\nreturn msg;","outputs":1,"x":310,"y":743.0000915527344,"z":"d8a3e781.275c18","wires":[["8b7e8fbf.74817"]]},{"id":"8b7e8fbf.74817","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":542.0000305175781,"y":744.0000915527344,"z":"d8a3e781.275c18","wires":[["6fc363d1.903c9c"]]},{"id":"6fc363d1.903c9c","type":"function","name":"Extract Graph Data","func":"msg.payload = msg.payload.raw;\n\nreturn msg;","outputs":1,"x":718.0000305175781,"y":749.0001525878906,"z":"d8a3e781.275c18","wires":[["2c3fc26c.d3c03e"]]},{"id":"2c3fc26c.d3c03e","type":"template","name":"Create the HTML","field":"payload","template":"<html>\n<head/>\n<body>\n<img src=\"data:image/svg+xml;,{{payload}}\" hieght=\"600\" width=\"800\"/>\n</body>\n</html","x":897.0000305175781,"y":748.0000915527344,"z":"d8a3e781.275c18","wires":[["2c51ec4d.d3ae14"]]},{"id":"dc388f81.23c77","type":"http in","name":"","url":"/graph","method":"get","x":95,"y":743.0000305175781,"z":"d8a3e781.275c18","wires":[["d0cbca4d.2f3438"]]},{"id":"2c51ec4d.d3ae14","type":"http response","name":"","x":1072.0002746582031,"y":752.0002746582031,"z":"d8a3e781.275c18","wires":[]},{"id":"d7396ed3.28c69","type":"comment","name":"Display Stream Graph","info":"","x":152.88888549804688,"y":667.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"271fafa5.d8e05","type":"inject","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":110.88888549804688,"y":435.8888854980469,"z":"d8a3e781.275c18","wires":[["84881931.7b77e8"]]},{"id":"84881931.7b77e8","type":"function","name":"Inject Random Temperature between 195 and 204","func":"var temp = Math.random()*10+ 195;\nmsg.topic = \"devices\";\nmsg.action = \"setStreamValue\";\nmsg.topic_id = \"1b2f98cc3b31b527c27ba14fe46c615c\";\nmsg.sub_topic_id = \"temperature\";\nmsg.payload = { \"at\": new Date().toJSON(), \"value\": temp}\nreturn msg;","outputs":1,"x":424.8888854980469,"y":434.8888854980469,"z":"d8a3e781.275c18","wires":[["2d33482e.d2ccb8"]]},{"id":"2d33482e.d2ccb8","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":747.8889465332031,"y":436.8888854980469,"z":"d8a3e781.275c18","wires":[["51afa1eb.ae506"]]},{"id":"51afa1eb.ae506","type":"debug","name":"","active":false,"console":"false","complete":"false","x":952.8889465332031,"y":410.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"c363ddcc.3c9c2","type":"comment","name":"Create Trigger for 200 degrees erase the previous one if exists first","info":"","x":255.88888549804688,"y":59.888885498046875,"z":"d8a3e781.275c18","wires":[]},{"id":"1a42bf38.e5bd41","type":"comment","name":"Inject temperature reading every 10 seconds","info":"","x":212.88888549804688,"y":331.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"8a1d6b15.75e298","type":"debug","name":"","active":true,"console":"false","complete":"false","x":468.8888854980469,"y":560.8889465332031,"z":"d8a3e781.275c18","wires":[]},{"id":"4daf277b.b250d8","type":"function","name":"Write log Message","func":"msg.payload = \"200 Limit was reached - \"+ msg.value + \" was recorded.\"\nreturn msg;","outputs":1,"x":278.8888854980469,"y":569.8888854980469,"z":"d8a3e781.275c18","wires":[["8a1d6b15.75e298"]]},{"id":"3e6d0518.c192fa","type":"comment","name":"Trigger critiria was met","info":"","x":127.88888549804688,"y":508.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"bb93efe4.446c1","type":"http in","name":"","url":"/create_trigger","method":"get","x":109.88888549804688,"y":195.88888549804688,"z":"d8a3e781.275c18","wires":[["37b9ce.ffc84632"]]},{"id":"dc56a763.23a958","type":"http response","name":"","x":1487.8889465332031,"y":258.8888854980469,"z":"d8a3e781.275c18","wires":[]},{"id":"d74083f6.28bf8","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":1387.8890686035156,"y":984.8889541625977,"z":"d8a3e781.275c18","wires":[["65891d8e.9a76e4","2d0a145.fd2f5ec"]]},{"id":"383105a6.c7cefa","type":"function","name":"Create m2x_node_red_distrib distribution","func":"msg.topic = \"distributions\";\nmsg.action = \"create\";\nmsg.payload = { \"name\" : \"m2x_node_red_distrib\",\"description\" : \"m2x ndoe red testing\", \"visibility\" : \"private\", \"base_device\" : \"1b2f98cc3b31b527c27ba14fe46c615c\"};\nreturn msg;","outputs":1,"x":1144.8890075683594,"y":989.8889350891113,"z":"d8a3e781.275c18","wires":[["d74083f6.28bf8"]]},{"id":"65891d8e.9a76e4","type":"debug","name":"","active":true,"console":"false","complete":"false","x":1567.8890686035156,"y":905.8889713287354,"z":"d8a3e781.275c18","wires":[]},{"id":"ddaeac57.22515","type":"comment","name":"Create m2x_node_red distribution and erase the previous one if exists first","info":"","x":310.8888854980469,"y":820.4444885253906,"z":"d8a3e781.275c18","wires":[]},{"id":"1a7ec325.e5813d","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":515.8889465332031,"y":904.6667060852051,"z":"d8a3e781.275c18","wires":[["45780a19.ba87f4"]]},{"id":"13213b64.ecdec5","type":"function","name":"Get All Distribution","func":"msg.topic = \"distributions\";\nmsg.action = \"list\";\nmsg.payload = {};\nreturn msg;","outputs":1,"x":326.8888854980469,"y":900.6667060852051,"z":"d8a3e781.275c18","wires":[["1a7ec325.e5813d"]]},{"id":"45780a19.ba87f4","type":"function","name":"Find the if m2x_node_red_distrib exists","func":"if (!msg.payload) {\n\tconsole.log(\"No Payload quit flow\");\n\tmsg.payload = -1;\n} else {\n\tif (!msg.payload.distributions) {\n\t\tconsole.log(\"No distributions found\");\n\t\tmsg.payload = -1;\n\t} \n\telse \n\t{\n\t\tvar distribs = msg.payload.distributions;\n\t\tfor(var distrib in distribs) {\n\t\t console.log(distribs[distrib].name);\n\t\t\tif (typeof (distribs[distrib].name) === 'string' && distribs[distrib].name === \"m2x_node_red_distrib\") {\t\t\t\t\n\t\t\tconsole.log(\"Distribution m2x_node_red_distrib found \"+ distribs[distrib].id);\n\t\t\tmsg.payload = distribs[distrib].id;\t\n\t\t\treturn msg;\n\t\t\t} \n\t\t}\n\t}\n}\nmsg.payload = -1;\nconsole.log(\"Counldn't find m2x_node_red_distrib distribution, go directly to create it\");\nreturn msg;","outputs":"1","x":778.8889465332031,"y":901.6667060852051,"z":"d8a3e781.275c18","wires":[["aed355c2.512ca8"]]},{"id":"aed355c2.512ca8","type":"switch","name":"","property":"payload","rules":[{"t":"neq","v":-1,"v2":0},{"t":"else"}],"checkall":"true","outputs":2,"x":1021.8890686035156,"y":904.6667175292969,"z":"d8a3e781.275c18","wires":[["332c2e44.ccd3d2"],["383105a6.c7cefa"]]},{"id":"e3c65244.1c39b","type":"http in","name":"","url":"/create_distribution","method":"get","x":109.77777099609375,"y":902.5555725097656,"z":"d8a3e781.275c18","wires":[["13213b64.ecdec5"]]},{"id":"332c2e44.ccd3d2","type":"function","name":"Delete m2x_node_red_distribution if exists","func":"console.log(msg.payload);\n\nmsg.topic = \"distributions\";\nmsg.action = \"deleteDistribution\";\nmsg.topic_id = msg.payload;\nmsg.payload = {};\nreturn msg;","outputs":1,"x":1186.8889465332031,"y":825.8889465332031,"z":"d8a3e781.275c18","wires":[["4392684c.bc6d98"]]},{"id":"4392684c.bc6d98","type":"m2x","feed":"704442f7.8fbbbc","name":"","x":1449.888916015625,"y":826.888916015625,"z":"d8a3e781.275c18","wires":[["383105a6.c7cefa"]]},{"id":"2d0a145.fd2f5ec","type":"http response","name":"","x":1581.888916015625,"y":984.7777709960938,"z":"d8a3e781.275c18","wires":[]}] |
{ | ||
"name": "node-red-m2x", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "A Node-RED node to AT&T M2X", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -28,3 +28,3 @@ node-red-m2x | ||
<li> msg.topic - The type of object to act on - distribution,device,chart.key. | ||
<li> msg.action - An action to be applied for this type of object | ||
<li> msg.action - An action to be applied for this type of object - The second level entry in the below list. (catalog for example) | ||
<li> msg.payload - A json that represent the body for the rest API, only if such is defiend. | ||
@@ -47,2 +47,3 @@ <li> msg.topic_id - a unique id for either device,distribution,key or chart | ||
</ul> | ||
<!--TODO: Missing Documentation what the payload should look like---> | ||
<li>createKey | ||
@@ -119,3 +120,5 @@ <ul> | ||
<li> msg.sub_topic_id - The stream name | ||
<li> msg.payload - parameters - the values | ||
<li> msg.payload - parameters - the values - | ||
<pre>[{ "timestamp": "timeStamp" "value": "value" }, | ||
{ "timestamp": "timeStamp","value": "value>"}]</pre> | ||
</ul> | ||
@@ -194,4 +197,3 @@ <li>sampleStreamValues | ||
</ul> | ||
<li>updateLocation | ||
<ul> | ||
<li>updateLocation <ul> | ||
<li><a href="https://m2x.att.com/developer/documentation/v2/device#Update-Device-Location"> Update a device location </a> | ||
@@ -203,3 +205,3 @@ <li> msg.topic_id - The device id | ||
<ul> | ||
<li><a href="https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream"> Update a data steam</a> | ||
<li><a href="https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream"> Update a data stream</a> | ||
<li> msg.topic_id - The device id | ||
@@ -211,3 +213,3 @@ <li> msg.sub_topic_id - The Name of the stream | ||
<ul> | ||
<li><a href="https://m2x.att.com/developer/documentation/v2/device#Update-Trigger"> Update a data steam</a> | ||
<li><a href="https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream"> Update a data stream</a> | ||
<li> msg.topic_id - The device id | ||
@@ -262,3 +264,3 @@ <li> msg.sub_topic_id - Array of streams names | ||
</ul> | ||
<li>deleteDataSream | ||
<li>deleteDataStream | ||
<ul> | ||
@@ -353,2 +355,7 @@ <li><a href="https://m2x.att.com/developer/documentation/v2/distribution#Delete-Data-Stream">Delete an existing data stream associated to distribution</a> | ||
<li>render | ||
<ul> | ||
<li><a href="https://m2x.att.com/developer/documentation/v2/charts#Render-Chart">Retrieve a rendering of a given chart as image format</a> | ||
<li>msg.topic_id - The chart id | ||
<li>msg.sub_topic_id - the image format : "svg" or "png" | ||
</ul> | ||
<li>update | ||
@@ -358,3 +365,3 @@ <ul> | ||
<li> msg.topic_id - The chart id | ||
<li> msg.payload - chart parameters | ||
<li> msg.payload - chart parameters -<pre>{ series : [{device: "device-id", stream:"stream_name" }]}</pre> | ||
</ul> | ||
@@ -368,3 +375,3 @@ <li>view | ||
</ul> | ||
<ul> | ||
<ul | ||
<li><b>keys</b> | ||
@@ -414,14 +421,18 @@ <ul> | ||
<div> | ||
<img src="./md_images/m2x.png"/> | ||
<H3> Examples </H3> | ||
<img src="./md_images/m2x.png"/> | ||
<H4> Create Chart </H4> | ||
<H4> Create Trigger </H4> | ||
<H5> Function Code </H5> | ||
<pre> | ||
msg.payload = { "name": "Single-device Chart",<br> | ||
"series": [<br> | ||
{ "device": "8a198ad5984605bcb6721c82e230a067", stream: "temperature" },<br> | ||
{ "device": "8a198ad5984605bcb6721c82e230a067", stream: "humidity" }<br> | ||
]<br> | ||
};<br> | ||
return msg;<br> | ||
msg.topic = "devices";<br> | ||
msg.action = "createTrigger";<br> | ||
msg.topic_id = "1b2f98cc3b31b527c27ba14fe46c615c";<br> | ||
msg.payload = { "stream": "heat", <br> | ||
"name": "Hightemperature3", <br> | ||
"condition": ">", <br> | ||
"value": 100, <br> | ||
"callback_url": "http://example.com", <br> | ||
"status": "enabled", <br> | ||
"send_location": true }; <br> | ||
</pre> | ||
@@ -437,2 +448,2 @@ <H4> Show device Details<H4> | ||
</div> | ||
</div> | ||
</div> |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
104078
12
15
932
437
2