From 6eec0345c201b2a2c02823894693c1f902f75ff6 Mon Sep 17 00:00:00 2001 From: Tobias Blum Date: Sat, 27 Jan 2018 22:55:45 +0100 Subject: [PATCH] NodeRed example for websocker proxy --- clients/node_red/websocket_proxy.json | 291 ++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 clients/node_red/websocket_proxy.json diff --git a/clients/node_red/websocket_proxy.json b/clients/node_red/websocket_proxy.json new file mode 100644 index 0000000..98cb3b6 --- /dev/null +++ b/clients/node_red/websocket_proxy.json @@ -0,0 +1,291 @@ +[ + { + "id": "60b3fe49.13b14", + "type": "tab", + "label": "McLighting Proxy", + "disabled": false, + "info": "" + }, + { + "id": "30663a5b.cc72c6", + "type": "http response", + "z": "60b3fe49.13b14", + "name": "", + "x": 770, + "y": 100, + "wires": [] + }, + { + "id": "cc64aa0d.b17bd8", + "type": "http in", + "z": "60b3fe49.13b14", + "name": "", + "url": "/mclighting", + "method": "get", + "upload": false, + "swaggerDoc": "", + "x": 140, + "y": 100, + "wires": [ + [ + "2f677b34.f2b934" + ] + ] + }, + { + "id": "2f677b34.f2b934", + "type": "template", + "z": "60b3fe49.13b14", + "name": "Simple Web Page", + "field": "payload", + "fieldType": "msg", + "format": "html", + "syntax": "mustache", + "template": "\n\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\n\t\t\n\t\t\n\t\t\n\t\tMcLighting v2\n\t\n\n\t\n\t\t\n\t\t\n\t\t
\n\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\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tsend\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\tTV\n\t\t\t\t\t\t\tsend\n\t\t\t\t\t\t\n\t\t\t\t\t
\n\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\tLoading animations...\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t
\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n", + "x": 470, + "y": 100, + "wires": [ + [ + "30663a5b.cc72c6" + ] + ] + }, + { + "id": "c9b17f3b.9dff8", + "type": "websocket in", + "z": "60b3fe49.13b14", + "name": "", + "server": "566e6e2.291cd9", + "client": "", + "x": 150, + "y": 320, + "wires": [ + [ + "269d49ad.a76b86", + "290609d3.6278b6" + ] + ] + }, + { + "id": "269d49ad.a76b86", + "type": "debug", + "z": "60b3fe49.13b14", + "name": "", + "active": true, + "console": "false", + "complete": "true", + "x": 770, + "y": 320, + "wires": [] + }, + { + "id": "c919144e.a042d8", + "type": "websocket out", + "z": "60b3fe49.13b14", + "name": "McLighting MASTER", + "server": "", + "client": "76c1e2a2.260edc", + "x": 720, + "y": 360, + "wires": [] + }, + { + "id": "290609d3.6278b6", + "type": "change", + "z": "60b3fe49.13b14", + "name": "", + "rules": [ + { + "t": "delete", + "p": "_session", + "pt": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 420, + "y": 360, + "wires": [ + [ + "c919144e.a042d8", + "66d9365b.ea4678" + ] + ] + }, + { + "id": "34867cb8.1e90c4", + "type": "websocket in", + "z": "60b3fe49.13b14", + "name": "McLighting MASTER", + "server": "", + "client": "76c1e2a2.260edc", + "x": 150, + "y": 540, + "wires": [ + [ + "895c4072.f2c8b", + "476937ec.2e6bc8" + ] + ] + }, + { + "id": "895c4072.f2c8b", + "type": "debug", + "z": "60b3fe49.13b14", + "name": "", + "active": false, + "console": "false", + "complete": "true", + "x": 770, + "y": 540, + "wires": [] + }, + { + "id": "60647cef.9d1b84", + "type": "websocket out", + "z": "60b3fe49.13b14", + "name": "", + "server": "566e6e2.291cd9", + "client": "", + "x": 730, + "y": 620, + "wires": [] + }, + { + "id": "476937ec.2e6bc8", + "type": "change", + "z": "60b3fe49.13b14", + "name": "", + "rules": [ + { + "t": "delete", + "p": "_session", + "pt": "msg" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 440, + "y": 580, + "wires": [ + [ + "60647cef.9d1b84" + ] + ] + }, + { + "id": "66d9365b.ea4678", + "type": "websocket out", + "z": "60b3fe49.13b14", + "name": "McLighting SLAVE 1", + "server": "", + "client": "a3ea760c.37e1c8", + "x": 720, + "y": 400, + "wires": [] + }, + { + "id": "78a93dec.7bbd84", + "type": "template", + "z": "60b3fe49.13b14", + "name": "Modes list", + "field": "payload", + "fieldType": "msg", + "format": "handlebars", + "syntax": "plain", + "template": "[{\"mode\":0, \"name\":\"Static\"},{\"mode\":1, \"name\":\"Blink\"},{\"mode\":2, \"name\":\"Breath\"},{\"mode\":3, \"name\":\"Color Wipe\"},{\"mode\":4, \"name\":\"Color Wipe Inverse\"},{\"mode\":5, \"name\":\"Color Wipe Reverse\"},{\"mode\":6, \"name\":\"Color Wipe Reverse Inverse\"},{\"mode\":7, \"name\":\"Color Wipe Random\"},{\"mode\":8, \"name\":\"Random Color\"},{\"mode\":9, \"name\":\"Single Dynamic\"},{\"mode\":10, \"name\":\"Multi Dynamic\"},{\"mode\":11, \"name\":\"Rainbow\"},{\"mode\":12, \"name\":\"Rainbow Cycle\"},{\"mode\":13, \"name\":\"Scan\"},{\"mode\":14, \"name\":\"Dual Scan\"},{\"mode\":15, \"name\":\"Fade\"},{\"mode\":16, \"name\":\"Theater Chase\"},{\"mode\":17, \"name\":\"Theater Chase Rainbow\"},{\"mode\":18, \"name\":\"Running Lights\"},{\"mode\":19, \"name\":\"Twinkle\"},{\"mode\":20, \"name\":\"Twinkle Random\"},{\"mode\":21, \"name\":\"Twinkle Fade\"},{\"mode\":22, \"name\":\"Twinkle Fade Random\"},{\"mode\":23, \"name\":\"Sparkle\"},{\"mode\":24, \"name\":\"Flash Sparkle\"},{\"mode\":25, \"name\":\"Hyper Sparkle\"},{\"mode\":26, \"name\":\"Strobe\"},{\"mode\":27, \"name\":\"Strobe Rainbow\"},{\"mode\":28, \"name\":\"Multi Strobe\"},{\"mode\":29, \"name\":\"Blink Rainbow\"},{\"mode\":30, \"name\":\"Chase White\"},{\"mode\":31, \"name\":\"Chase Color\"},{\"mode\":32, \"name\":\"Chase Random\"},{\"mode\":33, \"name\":\"Chase Rainbow\"},{\"mode\":34, \"name\":\"Chase Flash\"},{\"mode\":35, \"name\":\"Chase Flash Random\"},{\"mode\":36, \"name\":\"Chase Rainbow White\"},{\"mode\":37, \"name\":\"Chase Blackout\"},{\"mode\":38, \"name\":\"Chase Blackout Rainbow\"},{\"mode\":39, \"name\":\"Color Sweep Random\"},{\"mode\":40, \"name\":\"Running Color\"},{\"mode\":41, \"name\":\"Running Red Blue\"},{\"mode\":42, \"name\":\"Running Random\"},{\"mode\":43, \"name\":\"Larson Scanner\"},{\"mode\":44, \"name\":\"Comet\"},{\"mode\":45, \"name\":\"Fireworks\"},{\"mode\":46, \"name\":\"Fireworks Random\"},{\"mode\":47, \"name\":\"Merry Christmas\"},{\"mode\":48, \"name\":\"Fire Flicker\"},{\"mode\":49, \"name\":\"Fire Flicker (soft)\"},{\"mode\":50, \"name\":\"Fire Flicker (intense)\"},{\"mode\":51, \"name\":\"Circus Combustus\"},{\"mode\":52, \"name\":\"Halloween\"},{\"mode\":53, \"name\":\"Bicolor Chase\"},{\"mode\":54, \"name\":\"Tricolor Chase\"},{\"mode\":55, \"name\":\"ICU\"},{}]", + "output": "str", + "x": 470, + "y": 160, + "wires": [ + [ + "8639e406.b82e38" + ] + ] + }, + { + "id": "7cc35600.dc2558", + "type": "http in", + "z": "60b3fe49.13b14", + "name": "", + "url": "/get_modes", + "method": "get", + "upload": false, + "swaggerDoc": "", + "x": 140, + "y": 160, + "wires": [ + [ + "78a93dec.7bbd84" + ] + ] + }, + { + "id": "8639e406.b82e38", + "type": "http response", + "z": "60b3fe49.13b14", + "name": "", + "statusCode": "", + "headers": {}, + "x": 770, + "y": 160, + "wires": [] + }, + { + "id": "e1ce7b73.d32078", + "type": "comment", + "z": "60b3fe49.13b14", + "name": "HTTP server for the McLighting web page / modes list", + "info": "These is mainly the original source code from McLighting, just the endpoint were patched so that they match with Node Red.\nWeb page listens on http:///mclighting", + "x": 260, + "y": 60, + "wires": [] + }, + { + "id": "84c92c41.eb3a9", + "type": "comment", + "z": "60b3fe49.13b14", + "name": "Websocket Input -> split to multiple McLighting nodes", + "info": "You can output the message to multiple McLighting Nodes. \nJust add websocket output nodes for each McLighting.", + "x": 260, + "y": 280, + "wires": [] + }, + { + "id": "776ca012.6f1d4", + "type": "comment", + "z": "60b3fe49.13b14", + "name": "Websocket Output --> Get return value from MASTER and echo to web page", + "info": "", + "x": 330, + "y": 500, + "wires": [] + }, + { + "id": "566e6e2.291cd9", + "type": "websocket-listener", + "z": "60b3fe49.13b14", + "path": "/mclighting/ws", + "wholemsg": "false" + }, + { + "id": "76c1e2a2.260edc", + "type": "websocket-client", + "z": "", + "path": "ws://192.168.0.49:81", + "wholemsg": "false" + }, + { + "id": "a3ea760c.37e1c8", + "type": "websocket-client", + "z": "", + "path": "ws://192.168.0.64:81/", + "wholemsg": "false" + } +] \ No newline at end of file