Two simple flows for using with Dweet.io

There are two flows one for posting a Dweet, and one for getting the latest Dweet.

They both use a "Function" node and a "http request" node to build the URL (using the API spec on Dweet.io here: https://dweet.io/play/).

NOTE: That the function nodes will check for the existing of "msg.key" and pass that if it exists, this way you can use it with private/locked things.

[{"id":"109f0aef.ef60f5","type":"function","z":"47156e66.b8ea9","name":"EDIT: Add your \"thing\" and \"key\"...","func":"msg.thing = \"my-thing-uniqueid\";\n//msg.key = \"my-write-key\";\n\nmsg.type = \"POST\";\n\nif(msg.key)\n{\n  msg.url = \"https://dweet.io:443/dweet/for/\" + msg.thing + \"?key=\" + msg.key;\n}\nelse\n{\n  msg.url = \"https://dweet.io:443/dweet/for/\" + msg.thing;\n} // endif\n\nmsg.headers = {\"Content-Type\" : \"application/json\"};\n\nreturn msg;","outputs":1,"noerr":0,"x":265,"y":198,"wires":[["2c9d6a2f.d36296","f5aa8cbd.0a557","bdc6df68.42392"]]},{"id":"bdc6df68.42392","type":"http request","z":"47156e66.b8ea9","name":"","method":"POST","ret":"txt","url":"","tls":"","x":323,"y":293,"wires":[["50076bf7.aff894","e7629f7b.189d6"]]},{"id":"50076bf7.aff894","type":"debug","z":"47156e66.b8ea9","name":"Response: StatusCode","active":true,"console":"false","complete":"statusCode","x":618,"y":294,"wires":[]},{"id":"2c9d6a2f.d36296","type":"debug","z":"47156e66.b8ea9","name":"Request: URL","active":true,"console":"false","complete":"url","x":588.5,"y":184,"wires":[]},{"id":"5772b0f4.a88d5","type":"inject","z":"47156e66.b8ea9","name":"Example JSON to be Dweet-ed","topic":"","payload":"{ \"some\" : \"stuff\", \"to be\" : \"dweet-ed\" }","payloadType":"json","repeat":"","crontab":"","once":false,"x":185.5,"y":103,"wires":[["109f0aef.ef60f5"]]},{"id":"f5aa8cbd.0a557","type":"debug","z":"47156e66.b8ea9","name":"Request: Payload","active":true,"console":"false","complete":"payload","x":597.5,"y":225,"wires":[]},{"id":"b93240d8.46cdc","type":"function","z":"47156e66.b8ea9","name":"EDIT: Add your \"thing\" and \"key\"...","func":"msg.thing = \"my-thing-uniqueid\";\n//msg.key = \"my-write-key\";\n\nmsg.type = \"GET\";\n\nif(msg.key)\n{\n  msg.url = \"https://dweet.io:443/get/latest/dweet/for/\" + msg.thing + \"?key=\" + msg.key;\n}\nelse\n{\n  msg.url = \"https://dweet.io:443/get/latest/dweet/for/\" + msg.thing;\n} // endif\n\nreturn msg;","outputs":1,"noerr":0,"x":266.5,"y":483,"wires":[["a1d8237.f5e27e","fb8a73c4.04759"]]},{"id":"fb8a73c4.04759","type":"http request","z":"47156e66.b8ea9","name":"","method":"GET","ret":"txt","url":"","tls":"","x":324.5,"y":578,"wires":[["2a0129e0.d5fed6","1899ac43.e76654"]]},{"id":"2a0129e0.d5fed6","type":"debug","z":"47156e66.b8ea9","name":"Response: StatusCode","active":true,"console":"false","complete":"statusCode","x":645.5,"y":579,"wires":[]},{"id":"a1d8237.f5e27e","type":"debug","z":"47156e66.b8ea9","name":"Request: URL","active":true,"console":"false","complete":"url","x":612,"y":483,"wires":[]},{"id":"6c91e48a.936e1c","type":"inject","z":"47156e66.b8ea9","name":"Trigger /get/latest/dweet/for/","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":177,"y":388,"wires":[["b93240d8.46cdc"]]},{"id":"bdec25f6.4213d8","type":"comment","z":"47156e66.b8ea9","name":"NOTE: Use of \"key\" is optional, but required for a locked thing.","info":"","x":262.5,"y":47,"wires":[]},{"id":"1899ac43.e76654","type":"debug","z":"47156e66.b8ea9","name":"Response: Payload","active":true,"console":"false","complete":"payload","x":624.5,"y":541,"wires":[]},{"id":"e7629f7b.189d6","type":"debug","z":"47156e66.b8ea9","name":"Response: Payload","active":true,"console":"false","complete":"payload","x":597.5,"y":338,"wires":[]}]
IanManonthemoon

Flow Info

created 1 year, 1 month ago

Node Types

Core
  • comment (x1)
  • debug (x7)
  • function (x2)
  • http request (x2)
  • inject (x2)

Tags

  • Dweet.io
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option