Pimoroni's Flotilla First Steps

My first attempt (basically just a test) to use Node Red and Pimoroni's Flotilla Medium kit. It connects to a flotilla daemon via Web Sockets and display weather data into debug console. Inspired by this blog post.

[{"id":"36ac24c8.c953dc","type":"websocket-client","z":"d18c8454.2e7378","path":"ws://192.168.123.7:9395","wholemsg":"false"},{"id":"178dd4ed.e8722b","type":"inject","z":"d18c8454.2e7378","name":"","topic":"","payload":"ready","payloadType":"string","repeat":"","crontab":"","once":true,"x":90,"y":39,"wires":[["f06cf209.0f931"]]},{"id":"63c7302.f9c38d","type":"websocket in","z":"d18c8454.2e7378","name":"","server":"","client":"36ac24c8.c953dc","x":132,"y":100,"wires":[["fa451781.05bae8"]]},{"id":"f06cf209.0f931","type":"websocket out","z":"d18c8454.2e7378","name":"","server":"","client":"36ac24c8.c953dc","x":295,"y":39,"wires":[]},{"id":"fa451781.05bae8","type":"function","z":"d18c8454.2e7378","name":"Extract Message","func":"var payload, d, c, m, details;\n    \n    payload = msg.payload.slice(6);\n    \nswitch(payload[0]){\n    case 'u': // Flotilla Update\n        d = payload.trim().split(' ');\n        d.shift();\n        details = d.shift().split('/');\n        c = details[0];\n        m  = details[1];\n        node.send([\n            {payload:{'event':'update','channel':c, 'module':m, 'values':d}},\n            null,\n            null\n            ]);\n        break;\n    case 'd': // Flotilla Disconnect\n        return null;\n    case 'c': // Flotilla Connect\n        return null;\n    default:\n        return null;\n}","outputs":1,"noerr":0,"x":377,"y":100,"wires":[["a5adb337.5a525"]]},{"id":"4c2ad5d1.b3d52c","type":"function","z":"d18c8454.2e7378","name":"Filter Weather Values","func":"if( msg.payload.module == 'weather'){\n    msg.payload = msg.payload.values[0];\n    return msg;\n}\nreturn null;","outputs":1,"noerr":0,"x":621,"y":171,"wires":[["f218a277.0de76"]]},{"id":"f218a277.0de76","type":"debug","z":"d18c8454.2e7378","name":"","active":true,"console":"false","complete":"payload","x":602,"y":258,"wires":[]},{"id":"a5adb337.5a525","type":"delay","z":"d18c8454.2e7378","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":599,"y":99,"wires":[["4c2ad5d1.b3d52c"]]}]
graycrow

Flow Info

created 1 year, 4 months ago

Node Types

Core
  • debug (x1)
  • delay (x1)
  • function (x2)
  • inject (x1)
  • websocket in (x1)
  • websocket out (x1)
  • websocket-client (x1)

Tags

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