Skip to content

Instantly share code, notes, and snippets.

@WA4OSH

WA4OSH/README.md Secret

Created May 12, 2018 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WA4OSH/0f0000c1f2788ffa171000c0497417e2 to your computer and use it in GitHub Desktop.
Save WA4OSH/0f0000c1f2788ffa171000c0497417e2 to your computer and use it in GitHub Desktop.
Outernet Status Twitter Bot

This flow reads the status on an Outernet DreamCatcher board, selects certain fields and posts the results to Twitter.

Please see http://outernet.is

You will need to edit the Twitter node to use your own credentials.

[{"id":"fbb97f22.5258e","type":"http request","z":"e2431c30.6c29","name":"GET TunerStatus","method":"GET","ret":"obj","url":"http://192.168.0.13/DIRECT/getTunerStatus","tls":"","x":562,"y":131,"wires":[["b82bad4d.59dec"]]},{"id":"c115975e.f713d8","type":"inject","z":"e2431c30.6c29","name":"post id","topic":"Once every hour","payload":"2","payloadType":"str","repeat":"3600","crontab":"","once":false,"x":172,"y":131,"wires":[["18786e5b.32ff32"]]},{"id":"18786e5b.32ff32","type":"change","z":"e2431c30.6c29","name":"","rules":[{"t":"set","p":"post","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":362,"y":131,"wires":[["fbb97f22.5258e"]]},{"id":"b82bad4d.59dec","type":"function","z":"e2431c30.6c29","name":"Build Twitter Message","func":"var header = \"DreamCatcher Status\\n\"\nvar footer = \"http://outernet.is for more info\"\nstreamtype = parseInt(msg.payload.result.stream);\nvar stream = \"Stream= \";\nswitch(streamtype)\n{\n case 0:\n stream = stream + \"files\";\n break;\n case 1:\n stream = stream + \"one\";\n break;\n case 2:\n stream = stream + \"two\";\n break; \n default:\n stream = stream + \"unknown\";\n} \nstream = stream + \"\\n\"\nvar snr = \"SNR (dBm)= \" + msg.payload.result.snr +\"\\n\"\nif (msg.payload.result.lock == 1)\nvar lockyn = \"yes\"\nelse \n lockyn = \"no\";\nvar lock = \"Lock= \" + lockyn +\"\\n\";\nvar rssi = \"RSSI (dBm)= \" + msg.payload.result.rssi + \"\\n\";\nvar msg = { payload: header+stream+snr+lock+rssi}\nreturn msg;\n\n","outputs":1,"noerr":0,"x":252,"y":251,"wires":[["e48a6640.906518"]]},{"id":"521170b.95bf99","type":"comment","z":"e2431c30.6c29","name":"Typical TunerStatus JSON ","info":"{\n \"result\": {\n \"stream\": 0,\n \"td\": 97,\n \"bitrate\": 20093,\n \"packetrate\": 10.28,\n \"lock\": 1,\n \"freq\": 11902.14,\n \"snr\": -12.5,\n \"rssi\": -79,\n \"crc_ok\": 79487,\n \"crc_err\": 213,\n \"freq_offset\": 28344,\n \"freq_offset_uc\": -1463,\n \"transfers\": [\n {\n \"carousel_id\": 1,\n \"path\": \"opaks/6b63-BIOLOGY_TAHOSA_N.ZONE_2012_1509627348489.pdf.tbz2\",\n \"hash\": \"5f3703d4ab73be8c6bf6fb7947c4e3f646944daaeaf17192e76f70dda8787ebd\",\n \"block_count\": 3528,\n \"block_received\": 1314,\n \"complete\": 1\n },\n {}\n ]\n },\n \"error\": false\n}\n","x":482,"y":331,"wires":[]},{"id":"e48a6640.906518","type":"twitter out","z":"e2431c30.6c29","name":"Tweet","x":475,"y":247,"wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment