Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": "85f4feea.5ed1f",
- "type": "tab",
- "label": "Display Raspberry"
- },
- {
- "id": "370b18fe.766788",
- "type": "wiotp-credentials",
- "z": "",
- "name": "mvp1",
- "org": "fgorux",
- "devType": "rasspberrypi_fiducua",
- "devId": "raspberry_1"
- },
- {
- "id": "a01faff8.67bf9",
- "type": "wiotp-credentials",
- "z": "",
- "name": "mvp1",
- "org": "fgorux",
- "devType": "rasspberrypi_fiducua",
- "devId": "raspberry_1"
- },
- {
- "id": "9abbb7ca.778e28",
- "type": "wiotp-credentials",
- "z": "",
- "name": "Raspberry_1",
- "org": "kwbv6q",
- "devType": "Raspberry",
- "devId": "Raspberry_1"
- },
- {
- "id": "fb53e55d.8343e8",
- "type": "wiotp-credentials",
- "z": "",
- "name": "",
- "org": "lpol26",
- "devType": "Raspberry",
- "devId": "348267e0.e0e8f8"
- },
- {
- "id": "c253c6c8.f859c8",
- "type": "websocket-listener",
- "z": "85f4feea.5ed1f",
- "path": "/ws/simple",
- "wholemsg": "false"
- },
- {
- "id": "753fe9c8.bb8608",
- "type": "websocket out",
- "z": "85f4feea.5ed1f",
- "name": "",
- "server": "c253c6c8.f859c8",
- "client": "",
- "x": 989,
- "y": 522,
- "wires": []
- },
- {
- "id": "ff7fd53e.c01718",
- "type": "http response",
- "z": "85f4feea.5ed1f",
- "name": "",
- "x": 909,
- "y": 458,
- "wires": []
- },
- {
- "id": "8bd587fe.7db358",
- "type": "http in",
- "z": "85f4feea.5ed1f",
- "name": "",
- "url": "/simple",
- "method": "get",
- "swaggerDoc": "",
- "x": 463,
- "y": 460,
- "wires": [
- [
- "a674708.6b1dc9"
- ]
- ]
- },
- {
- "id": "a674708.6b1dc9",
- "type": "template",
- "z": "85f4feea.5ed1f",
- "name": "Vending Machine",
- "field": "payload",
- "fieldType": "msg",
- "format": "html",
- "syntax": "mustache",
- "template": "<!DOCTYPE HTML>\n<html>\n <head>\n \n <title>Simple Live Display</title>\n\n <script type=\"text/javascript\">\n var ws;\n var wsUri = \"ws:\";\n var loc = window.location;\n console.log(loc);\n if (loc.protocol === \"https:\") { wsUri = \"wss:\"; }\n // This needs to point to the web socket in the Node-RED flow\n // ... in this case it's ws/simple\n wsUri += \"//\" + loc.host + loc.pathname.replace(\"simple\",\"ws/simple\");\n\n function wsConnect() {\n console.log(\"connect\",wsUri);\n ws = new WebSocket(wsUri);\n //var line = \"\"; // either uncomment this for a building list of messages\n ws.onmessage = function(msg) {\n var line = \"\"; // or uncomment this to overwrite the existing message\n // parse the incoming message as a JSON object\n var data = msg.data;\n //console.log(\"data \" + (JSON.parse(data)).d.message );\n // build the output from the topic and payload parts of the object\n line += \"<span class='user-phrase' >\"+ \"Thanks \"+ (JSON.parse(data)).d.name + \"! Collect your \" + (JSON.parse(data)).d.product +\".</span>\";\n // replace the messages div with the new \"line\"\n document.getElementById('messages').innerHTML = line;\n //ws.send(JSON.stringify({data:data}));\n }\n ws.onopen = function() {\n // update the status div with the connection status\n document.getElementById('status').innerHTML = \"connected\";\n //ws.send(\"Open for data\");\n console.log(\"connected\");\n }\n ws.onclose = function() {\n // update the status div with the connection status\n document.getElementById('status').innerHTML = \"not connected\";\n // in case of lost connection tries to reconnect every 3 secs\n setTimeout(wsConnect,3000);\n }\n }\n \n function doit(m) {\n if (ws) { ws.send(m); }\n }\n </script>\n </head>\n <body style=\"margin: 0px; padding: 0px;\" onload=\"wsConnect();\" onunload=\"ws.disconnect();\">\n \n\t\t<div class=\"outer-div\">\n\t\t\t<div class=\"form-div\">\n\t\t\t\t<div class=\"sucess-msg\">\n\n\t\t\t <div id=\"messages\"></div>\n\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n \n <!--\n <button type=\"button\" onclick='doit(\"click\");'>Click to send message</button>\n \n\n <div id=\"status\">\n unknown</div>\n -->\n \n <style>\n .outer-div{\n width: 100vw;\n height: 100vh;\n background: #F8F8F8;\n position: relative;\n }\n\n .sucess-msg{\n text-align: center;\n padding-top: 14.3%;\n\n }\n\n .form-div{\n border-width: 4px;\n border-style: solid;\n border-color: #ff6600;\n border-radius: 9px;\n text-align: center;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n width: 60%;\n height: 60%;\n margin: auto;\n }\n\n .body{\n margin: 0px;\n }\n\n .user-phrase{\n padding-top: 7.1%;\n display: block;\n font: serif;\n font-size: 32px;\n font-weight: 800;\n color: #0066b3;\n }\n\n .user-options{\n padding-top: 4%;\n }\n\n .button::-moz-focus-inner{\n border: 0;\n padding: 0;\n }\n\n .button{\n display: inline-block;\n *display: inline;\n zoom: 1;\n padding: 6px 20px;\n margin: 0;\n cursor: pointer;\n border: 1px solid #bbb;\n overflow: visible;\n font: bold 13px arial, helvetica, sans-serif;\n text-decoration: none;\n white-space: nowrap;\n color: #555;\n </style>\n \n </body>\n\n</html>",
- "x": 736,
- "y": 456,
- "wires": [
- [
- "ff7fd53e.c01718"
- ]
- ]
- },
- {
- "id": "fde91aec.b1a588",
- "type": "function",
- "z": "85f4feea.5ed1f",
- "name": "format time nicely",
- "func": "//msg.payload = Date(msg.payload).toString();\nreturn msg;",
- "outputs": 1,
- "noerr": 0,
- "x": 726,
- "y": 518,
- "wires": [
- [
- "753fe9c8.bb8608"
- ]
- ]
- },
- {
- "id": "bd924449.34cfd8",
- "type": "websocket in",
- "z": "85f4feea.5ed1f",
- "name": "",
- "server": "c253c6c8.f859c8",
- "client": "",
- "x": 732,
- "y": 593,
- "wires": [
- [
- "f8d27668.54f8b8"
- ]
- ]
- },
- {
- "id": "f8d27668.54f8b8",
- "type": "debug",
- "z": "85f4feea.5ed1f",
- "name": "",
- "active": true,
- "console": "false",
- "complete": "payload",
- "x": 967,
- "y": 593,
- "wires": []
- },
- {
- "id": "ba826c5d.93e72",
- "type": "wiotp in",
- "z": "85f4feea.5ed1f",
- "authType": "d",
- "deviceKey": "9abbb7ca.778e28",
- "deviceType": "",
- "deviceId": "",
- "command": "+",
- "commandType": "g",
- "name": " Raspberry_1",
- "x": 477,
- "y": 517,
- "wires": [
- [
- "fde91aec.b1a588"
- ]
- ]
- },
- {
- "id": "fec09ca.3e8656",
- "type": "wiotp in",
- "z": "85f4feea.5ed1f",
- "authType": "d",
- "deviceKey": "9abbb7ca.778e28",
- "deviceType": "",
- "deviceId": "",
- "command": "+",
- "commandType": "g",
- "name": " Raspberry_1",
- "x": 552,
- "y": 182,
- "wires": [
- [
- "c3273fa2.88613"
- ]
- ]
- },
- {
- "id": "c3273fa2.88613",
- "type": "debug",
- "z": "85f4feea.5ed1f",
- "name": "",
- "active": true,
- "console": "false",
- "complete": "true",
- "x": 821,
- "y": 180,
- "wires": []
- },
- {
- "id": "fd794c65.a1014",
- "type": "comment",
- "z": "85f4feea.5ed1f",
- "name": "Live display - Raspberry",
- "info": "",
- "x": 735.5,
- "y": 374,
- "wires": []
- },
- {
- "id": "7810e391.f37a4c",
- "type": "comment",
- "z": "85f4feea.5ed1f",
- "name": "Debug window Report",
- "info": "",
- "x": 677,
- "y": 112,
- "wires": []
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement