The purpose of this example (Node-RED as a trigger) is to collect Sequence of Events(SOE) and store in Google Sheets for later use.
Please follow Patrick Murray's instructions from How To Quickly Collect Data And Run Reports (or https://learnavprogramming.com/avit/how-to-quickly-collect-data-and-run-reports/ ) to configure IFTTT applets with webhooks.
If This Then That, also known as IFTTT is a free web-based service to create chains of simple conditional statements, called applets. An applet is triggered by changes that occur within other web services such as Gmail, Facebook, Telegram, Instagram, or Pinterest. ...from wikipedia
See Also :
Webhooks
Integrate other services on IFTTT with your DIY projects. You can create Applets that work with any device or app that can make or receive a web request. If you'd like to build your own service and Applets. ...from ifttt.com
You will find {{KEY}}
from Webhooks settings. For example, https://maker.ifttt.com/use/{{KEY}}
.
Edited flow from iot-device-simulator-2-stringify. Created two iot simulators to send SOE record (Event Type, ZIP, UV index).
The format of URL is https://maker.ifttt.com/trigger/{{EVENT NAME}}/with/key/{{KEY}}
for http-request
node. {{EVENT NAME}}
is soe
for this example.
Example Flow :
[{"id":"806f5c78.82d99","type":"debug","z":"e3776a69.34a108","name":"Display msg.payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":581.01953125,"y":307.5537796020508,"wires":[]},{"id":"b556e9a3.c30a58","type":"inject","z":"e3776a69.34a108","name":"Sensor Trigger","topic":"","payload":"","payloadType":"date","repeat":"4","crontab":"","once":true,"onceDelay":"1","x":153.01913452148438,"y":388.75370597839355,"wires":[["2be87c3e.77be24"]]},{"id":"2be87c3e.77be24","type":"iot-simulator","z":"e3776a69.34a108","name":"","options":[{"label":"UV_Index","value":"6","range":"5"},{"label":"Latitude","value":"40.730610","range":"0"},{"label":"Longitude","value":"-73.935242","range":"0"},{"label":"ZIPCode","value":"10001","range":"0"}],"preOptions":[{"label":"UV_Index","value":"9","range":"3"},{"label":"Latitude","value":"40.730610","range":"0"},{"label":"Longitude","value":"-73.935242","range":"0"},{"label":"ZIPCode","value":"10001","range":"0"}],"timestamp":true,"allinone":true,"optionEdited":false,"x":343.0193290710449,"y":388.6204357147217,"wires":[["806f5c78.82d99","abaf046a.780e38","ac1ea8b.cdbb658"]]},{"id":"abaf046a.780e38","type":"function","z":"e3776a69.34a108","name":"Payload Split","func":"\n// works with all-in-on or not.\nvar msg1 = null\nif ( msg.payload[\"UV_Index\"] !== undefined){\n msg1 = {};\n msg1.payload = msg.payload[\"UV_Index\"];\n}\nreturn msg1;","outputs":1,"noerr":0,"x":547.0194625854492,"y":457.82039642333984,"wires":[["33cecd1.2deea32","81269dcd.186d7"]]},{"id":"33cecd1.2deea32","type":"mqtt out","z":"e3776a69.34a108","name":"","topic":"ny-10001/uv-sensor","qos":"","retain":"","broker":"58eb1125.d56d8","x":867.0509948730469,"y":429.0314016342163,"wires":[]},{"id":"6c562540.0d987c","type":"mqtt in","z":"e3776a69.34a108","name":"ny-10001/+","topic":"ny-10001/+","qos":"0","broker":"58eb1125.d56d8","x":715.0391082763672,"y":237.77739906311035,"wires":[["760d0833.59dfd8"]]},{"id":"760d0833.59dfd8","type":"debug","z":"e3776a69.34a108","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":904.0509166717529,"y":237.07818031311035,"wires":[]},{"id":"a0d1cf75.750cc","type":"function","z":"e3776a69.34a108","name":"MQTT Broker Annoucement","func":"\n// https://www.npmjs.com/package/bonjour\nvar bonjour = require('bonjour')()\nvar service = flow.get(\"service\") || null;\n\nbonjour.unpublishAll(); \n\nif (service) {\n service.stop();\n}\n\n// advertise MQTT server\nvar service = bonjour.publish({ name: 'MQTT broker', \n type: 'mqtt', \n txt : { clientid : 'ny-10001-sensor1'},\n port: 1883 });\n\nflow.set('service', service);\n\nreturn null;","outputs":1,"noerr":0,"x":400.0508975982666,"y":80.5703296661377,"wires":[[]]},{"id":"8bf74cba.cbca2","type":"inject","z":"e3776a69.34a108","name":"","topic":"Started!","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"0.1","x":132.03910064697266,"y":80.8632755279541,"wires":[["a0d1cf75.750cc","98628bf0.26cb58"]]},{"id":"f8c86fa7.e52b4","type":"function","z":"e3776a69.34a108","name":"MQTT service finder","func":"https://https://www.npmjs.com/package/bonjour\nvar bonjour = require('bonjour')()\n \n// browse for all http services\nbonjour.find({ type: 'mqtt' }, function (service) {\n console.log('Found an MQTT broker:', service)\n \n})\n\nreturn null;","outputs":1,"noerr":0,"x":900.0470123291016,"y":78.57035827636719,"wires":[[]]},{"id":"e095e127.75615","type":"inject","z":"e3776a69.34a108","name":"","topic":"Test MQTT finder","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":684.0508346557617,"y":77.85159301757812,"wires":[["f8c86fa7.e52b4"]]},{"id":"adbcd96c.14fb18","type":"comment","z":"e3776a69.34a108","name":"Debug : find MQTT service","info":"","x":682.7890625,"y":40,"wires":[]},{"id":"ffa85965.02e6c8","type":"comment","z":"e3776a69.34a108","name":"Start MQTT Service/Publish","info":"","x":173.05081176757812,"y":43.00000858306885,"wires":[]},{"id":"3c030a4.a572ff6","type":"comment","z":"e3776a69.34a108","name":"New York - Temperature, Air Quality, UV Index","info":"","x":220.05081176757812,"y":342.99999141693115,"wires":[]},{"id":"4222b37d.53265c","type":"comment","z":"e3776a69.34a108","name":"Mosca MQTT Broker","info":"","x":143.04302978515625,"y":206.00006771087646,"wires":[]},{"id":"bef907fe.785078","type":"comment","z":"e3776a69.34a108","name":"MQTT subscriber \"ny-10001/+\"","info":"","x":771.0469360351562,"y":198.98834419250488,"wires":[]},{"id":"db6b9a4f.853578","type":"comment","z":"e3776a69.34a108","name":"MQTT publisher","info":"","x":845.7971496582031,"y":391.24225425720215,"wires":[]},{"id":"9af93bff.3c3028","type":"debug","z":"e3776a69.34a108","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":330.04691314697266,"y":252.0625410079956,"wires":[]},{"id":"87bc758c.d62d28","type":"mosca in","z":"e3776a69.34a108","mqtt_port":1883,"mqtt_ws_port":8080,"name":"","username":"","password":"","dburl":"","x":144.04300689697266,"y":251.18752551078796,"wires":[["9af93bff.3c3028"]]},{"id":"ee195af3.7611f8","type":"http request","z":"e3776a69.34a108","name":"","method":"POST","ret":"txt","url":"https://maker.ifttt.com/trigger/soe/with/key/beKFAg0zT1B3EpHA_XEY_z","tls":"","x":575.519603729248,"y":120.81250286102295,"wires":[["a4cb2b4f.f05538"]]},{"id":"98628bf0.26cb58","type":"function","z":"e3776a69.34a108","name":"IFTTT Event Report","func":"msg.event = \"soe\";\n\n// value1 : event type\n// value2 : plocation zip code \n// value3 : UV Index\nmsg.payload = {\n value1 : \"re-deploy\",\n value2 : \"10001\",\n value3 : \"0\"\n};\n\nreturn msg;","outputs":1,"noerr":0,"x":372.5195846557617,"y":120.91408061981201,"wires":[["ee195af3.7611f8"]]},{"id":"a4cb2b4f.f05538","type":"debug","z":"e3776a69.34a108","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":752.5158061981201,"y":120.9101676940918,"wires":[]},{"id":"df4f5a5e.9876b8","type":"inject","z":"e3776a69.34a108","name":"Trigger Deploy Event","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":154.26950073242188,"y":137.6875410079956,"wires":[["98628bf0.26cb58"]]},{"id":"ea9898fd.b3a0d8","type":"http request","z":"e3776a69.34a108","name":"","method":"POST","ret":"txt","url":"https://maker.ifttt.com/trigger/soe/with/key/beKFAg0zT1B3EpHA_XEY_z","tls":"","x":760.2696838378906,"y":354.5039587020874,"wires":[["41fd0b44.061524"]]},{"id":"ac1ea8b.cdbb658","type":"function","z":"e3776a69.34a108","name":"IFTTT Event Report","func":"var newMsg = {};\n// value1 : event type\n// value2 : plocation zip code \n// value3 : UV Index\n\nnewMsg.event = \"soe\";\nnewMsg.payload = { value1 : \"measure\",\n value2 : msg.payload.ZIPCode, \n value3 : msg.payload.UV_Index\n};\nreturn newMsg;","outputs":1,"noerr":0,"x":575.2694702148438,"y":355.60548973083496,"wires":[["ea9898fd.b3a0d8"]]},{"id":"41fd0b44.061524","type":"debug","z":"e3776a69.34a108","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":923.2657585144043,"y":354.6016082763672,"wires":[]},{"id":"81269dcd.186d7","type":"ui_chart","z":"e3776a69.34a108","name":"UV Index","group":"9d5aa45e.88a958","order":0,"width":"12","height":"6","label":"NYC","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":true,"ymin":"0","ymax":"13","removeOlder":1,"removeOlderPoints":"100","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":819.7696380615234,"y":481.9727392196655,"wires":[[],[]]},{"id":"40e405d0.f78dcc","type":"debug","z":"e3776a69.34a108","name":"Display msg.payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":582.0004196166992,"y":714.5039510726929,"wires":[]},{"id":"b5384745.4800e8","type":"inject","z":"e3776a69.34a108","name":"Sensor Trigger","topic":"","payload":"","payloadType":"date","repeat":"3","crontab":"","once":true,"onceDelay":"2","x":150,"y":601.7038640975952,"wires":[["63da012c.a898f"]]},{"id":"63da012c.a898f","type":"iot-simulator","z":"e3776a69.34a108","name":"","options":[{"label":"UV_Index","value":"6","range":"5"},{"label":"Latitude","value":"40.728157","range":"0"},{"label":"Longitude","value":"-74.077644","range":"0"},{"label":"ZIPCode","value":"07030","range":"0"}],"preOptions":[{"label":"UV_Index","value":"9","range":"3"},{"label":"Latitude","value":"40.728157","range":"0"},{"label":"Longitude","value":"-74.077644","range":"0"},{"label":"ZIPCode","value":"07030","range":"0"}],"timestamp":true,"allinone":true,"optionEdited":false,"x":339.0001850128174,"y":601.5705795288086,"wires":[["40e405d0.f78dcc","979ec883.622c38","ed74173e.5717d8"]]},{"id":"979ec883.622c38","type":"function","z":"e3776a69.34a108","name":"Payload Split","func":"\n// works with all-in-on or not.\nvar msg1 = null\nif ( msg.payload[\"UV_Index\"] !== undefined){\n msg1 = {};\n msg1.payload = msg.payload[\"UV_Index\"];\n}\nreturn msg1;","outputs":1,"noerr":0,"x":550.0003280639648,"y":502.7705535888672,"wires":[["289004a5.31bf3c"]]},{"id":"876199db.600f58","type":"comment","z":"e3776a69.34a108","name":"Jersey City - Temperature, Air Quality, UV Index","info":"","x":232.26953125,"y":556.2538976669312,"wires":[]},{"id":"9a5890a7.e7064","type":"http request","z":"e3776a69.34a108","name":"","method":"POST","ret":"txt","url":"https://maker.ifttt.com/trigger/soe/with/key/beKFAg0zT1B3EpHA_XEY_z","tls":"","x":756.0195770263672,"y":666.7538909912109,"wires":[["cd381974.5c1268"]]},{"id":"ed74173e.5717d8","type":"function","z":"e3776a69.34a108","name":"IFTTT Event Report","func":"var newMsg = {};\n// value1 : event type\n// value2 : plocation zip code \n// value3 : UV Index\n\nnewMsg.event = \"soe\";\nnewMsg.payload = { value1 : \"measure\",\n value2 : msg.payload.ZIPCode, \n value3 : msg.payload.UV_Index\n};\nreturn newMsg;","outputs":1,"noerr":0,"x":571.0193405151367,"y":664.8554382324219,"wires":[["9a5890a7.e7064"]]},{"id":"cd381974.5c1268","type":"debug","z":"e3776a69.34a108","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":920.0156669616699,"y":667.8515625,"wires":[]},{"id":"289004a5.31bf3c","type":"ui_chart","z":"e3776a69.34a108","name":"UV Index","group":"9d5aa45e.88a958","order":0,"width":"12","height":"6","label":"Jersey City","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":true,"ymin":"0","ymax":"13","removeOlder":1,"removeOlderPoints":"100","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#b4210d","#aec7e8","#ff7f0e","#2ca02c","#df194b","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":817.0195579528809,"y":522.7538967132568,"wires":[[],[]]},{"id":"58eb1125.d56d8","type":"mqtt-broker","z":"","name":"ny-10001-sensor1","broker":"localhost","port":"1883","clientid":"ny-10001-sensor1","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"9d5aa45e.88a958","type":"ui_group","z":"","name":"UV Index","tab":"21cb1b5f.bdccb4","order":2,"disp":true,"width":"12","collapse":false},{"id":"21cb1b5f.bdccb4","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]