Guest User

Node-red test 備份

a guest
Jun 2nd, 2017
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 9.72 KB | None | 0 0
  1. [{"id":"10d02d81.50ef92","type":"comment","z":"cd10f797.653218","name":"網頁及時查看溫溼度","info":"","x":110,"y":60,"wires":[]},{"id":"8fb5895b.bf5808","type":"http in","z":"cd10f797.653218","name":"","url":"/looktemphum","method":"get","swaggerDoc":"","x":110,"y":120,"wires":[["5f5e344d.9cd3fc"]]},{"id":"5f5e344d.9cd3fc","type":"template","z":"cd10f797.653218","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\n<a href=\"http://iot.local:1885/temphum\"  >\n    \n    \n    <button type=\"button\">\n   \n   查看資料\n    \n    </button>\n    \n    </a>","x":330,"y":120,"wires":[["98c7f24.f024a1"]]},{"id":"7858f439.2b151c","type":"function","z":"cd10f797.653218","name":"感測溫濕度","func":"var sensor = global.get('sensor');\n\nsensor.initialize(11, 4);\nvar readout = sensor.read();\nmsg.topic=\"temp\";\nmsg.payload = { 溫度:readout.temperature.toFixed(2) + \" 度C\" , 濕度:readout.humidity.toFixed(2) + \" %\" };\nconsole.log(msg);\nreturn msg;\n","outputs":1,"noerr":0,"x":390,"y":200,"wires":[["63992159.f0893","993200c2.9efee"]]},{"id":"63992159.f0893","type":"debug","z":"cd10f797.653218","name":"","active":true,"console":"false","complete":"false","x":670,"y":260,"wires":[]},{"id":"1c27785c.81f478","type":"http in","z":"cd10f797.653218","name":"","url":"/temphum","method":"get","swaggerDoc":"","x":110,"y":200,"wires":[["7858f439.2b151c"]]},{"id":"993200c2.9efee","type":"http response","z":"cd10f797.653218","name":"","x":690,"y":200,"wires":[]},{"id":"98c7f24.f024a1","type":"http response","z":"cd10f797.653218","name":"","x":490,"y":120,"wires":[]},{"id":"d0c820a9.112a7","type":"wiotp out","z":"cd10f797.653218","authType":"d","qs":"true","qsDeviceId":"","deviceType":"","deviceId":"","event":"","format":"json","name":"","x":560,"y":4280,"wires":[]},{"id":"83b46515.2ddc68","type":"inject","z":"cd10f797.653218","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"x":160,"y":4280,"wires":[["ec6563f4.193fe"]]},{"id":"ec6563f4.193fe","type":"function","z":"cd10f797.653218","name":"Generate time data","func":"// Convert timestamp in milliseconds to a number in 0-20 range\nmsg.payload = Math.floor((msg.payload/1000))%20;\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":4280,"wires":[["d0c820a9.112a7"]]},{"id":"43586b1.899d794","type":"comment","z":"cd10f797.653218","name":"Simple time inject to Watson IoT","info":"Sends data to Watson IoT Platform every two seconds.\n\nAfter deploying the example, open the Watson IoT\nnode and click the button to take you to the Quickstart\ndashboard for your flow.\n\n","x":210,"y":4240,"wires":[]},{"id":"195ddf06.a6d141","type":"file in","z":"cd10f797.653218","name":"flows_vps.json","filename":"/home/pi/.node-red/flows_iot.json","format":"utf8","x":280,"y":420,"wires":[["730bf147.2990c"]]},{"id":"4657752d.f93b3c","type":"file","z":"cd10f797.653218","name":"","filename":"","appendNewline":false,"createDir":false,"overwriteFile":"true","x":650,"y":420,"wires":[]},{"id":"20a8d1d6.911d6e","type":"inject","z":"cd10f797.653218","name":"","topic":"","payload":"restarted","payloadType":"str","repeat":"","crontab":"","once":true,"x":70,"y":420,"wires":[["195ddf06.a6d141","ca97a510.f13e38"]]},{"id":"730bf147.2990c","type":"function","z":"cd10f797.653218","name":"","func":"msg.filename = \"~/.node-red/backup_\"+(new Date().toISOString().replace(':', '_').replace(':', '_').replace(/\\..+/, ''))+\"_flows_vps.json\";\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":420,"wires":[["4657752d.f93b3c"]]},{"id":"ca97a510.f13e38","type":"file in","z":"cd10f797.653218","name":"flows_vps_cred.json","filename":"/home/pi/.node-red/flows_iot_cred.json","format":"utf8","x":300,"y":480,"wires":[["d4d04886.d77338"]]},{"id":"e2b8411c.19951","type":"file","z":"cd10f797.653218","name":"","filename":"","appendNewline":false,"createDir":false,"overwriteFile":"true","x":630,"y":480,"wires":[]},{"id":"d4d04886.d77338","type":"function","z":"cd10f797.653218","name":"","func":"msg.filename = \"~/.node-red/backup_\"+(new Date().toISOString().replace(':', '_').replace(':', '_').replace(/\\..+/, ''))+\"_flows_vps_cred.json\";\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":480,"wires":[["e2b8411c.19951"]]},{"id":"a3994338.68ad7","type":"comment","z":"cd10f797.653218","name":"另外種聊天室","info":"","x":119.01421356201172,"y":620.7329711914062,"wires":[]},{"id":"e5eb9b0a.652248","type":"websocket in","z":"cd10f797.653218","name":"","server":"545dbcd.4d90e44","x":114.5170669555664,"y":706.8351821899414,"wires":[["bea2b0eb.c6936"]]},{"id":"bea2b0eb.c6936","type":"function","z":"cd10f797.653218","name":"","func":"delete msg._session;\nreturn msg;\n\n","outputs":1,"x":288.5170669555664,"y":706.8351821899414,"wires":[["ab86d75d.eee1c8"]]},{"id":"ab86d75d.eee1c8","type":"websocket out","z":"cd10f797.653218","name":"","server":"545dbcd.4d90e44","x":469.5170669555664,"y":706.8351821899414,"wires":[]},{"id":"a078b771.084158","type":"http in","z":"cd10f797.653218","name":"","url":"/chatMe","method":"get","swaggerDoc":"","x":132.5170669555664,"y":774.8351821899414,"wires":[["c9f91dcf.7ae93"]]},{"id":"c9f91dcf.7ae93","type":"template","z":"cd10f797.653218","name":"","field":"","fieldType":"msg","syntax":"mustache","template":"<head>\n    \n    <script type=\"text/javascript\">\n  var wsUri1 = \"wss://{{req.headers.host}}/ws/chat\";\n  var ws1 = new WebSocket(wsUri1);\n\n  function createSystemMessage(message) {\n    var message = document.createTextNode(message);\n\n    var messageBox = document.createElement('p');\n    messageBox.className = 'system';\n\n    messageBox.appendChild(message);\n\n    var chat = document.getElementById('chat_box');\n    chat.appendChild(messageBox);\n  }\n\n  function createUserMessage(user, message) {\n    var user = document.createTextNode(user + ': ');\n\n    var userBox = document.createElement('span');\n    userBox.className = 'username';\n    userBox.appendChild(user);\n\n    var message = document.createTextNode(message);\n\n    var messageBox = document.createElement('p');\n    messageBox.appendChild(userBox);\n    messageBox.appendChild(message);\n\n    var chat = document.getElementById('chat_box');\n    chat.appendChild(messageBox);\n  }\n\n  ws1.onopen = function(ev) {\n    createSystemMessage('[Connected]');\n  };\n\n  ws1.onclose = function(ev) {\n    createSystemMessage('[Disconnected]');\n  }\n\n  ws1.onmessage = function(ev) {\n    var payload = JSON.parse(ev.data);\n    createUserMessage(payload.user, payload.message);\n\n    var chat = document.getElementById('chat_box');\n    chat.scrollTop = chat.scrollHeight;\n  }\n\n  function sendMessage() {\n    var user = document.getElementById('user');\n    var message = document.getElementById('message');\n\n    var payload = {\n      message: message.value,\n      user: user.value,\n      ts: (new Date()).getTime()\n    };\n\n    ws1.send(JSON.stringify(payload));\n    message.value = \"\";\n  };\n</script>\n    \n    \n  <meta name=\"viewport\" content=\"width=320, initial-scale=1\">\n  <title>Chat</title>\n</head>\n\n\n\n<body>\n    \n    <style type=\"text/css\">\n  * {\n    font-family: \"Palatino Linotype\", \"Book Antiqua\", Palatino, serif;\n    font-style: italic;\n    font-size: 24px;\n  }\n\n  html, body, #wrapper {\n    margin: 0;\n    padding: 0;\n    height: 100%;\n  }\n\n  #wrapper {\n    background-color: #ecf0f1;\n  }\n\n  #chat_box {\n    box-sizing: border-box;\n    height: 100%;\n    overflow: auto;\n    padding-bottom: 50px;\n  }\n\n  #footer {\n    box-sizing: border-box;\n    position: fixed;\n    bottom: 0;\n    height: 50px;\n    width: 100%;\n    background-color: #2980b9;\n  }\n\n  #footer .content {\n    padding-top: 4px;\n    position: relative;\n  }\n\n  #user { width: 20%; }\n  #message { width: 68%; }\n  #send_btn {\n    width: 10%;\n    position: absolute;\n    right: 0;\n    bottom: 0;\n    margin: 0;\n  }\n\n  .content {\n    width: 70%;\n    margin: 0 auto;\n  }\n\n  input[type=\"text\"],\n  input[type=\"button\"] {\n    border: 0;\n    color: #fff;\n  }\n\n  input[type=\"text\"] {\n    background-color: #146EA8;\n    padding: 3px 10px;\n  }\n\n  input[type=\"button\"] {\n    background-color: #f39c12;\n    border-right: 2px solid #e67e22;\n    border-bottom: 2px solid #e67e22;\n    min-width: 70px;\n    display: inline-block;\n  }\n\n  input[type=\"button\"]:hover {\n    background-color: #e67e22;\n    border-right: 2px solid #f39c12;\n    border-bottom: 2px solid #f39c12;\n    cursor: pointer;\n  }\n\n  .system,\n  .username {\n    color: #aaa;\n    font-style: italic;\n    font-family: monospace;\n    font-size: 16px;\n  }\n\n  @media(max-width: 1000px) {\n    .content { width: 90%; }\n  }\n\n  @media(max-width: 780px) {\n    #footer { height: 91px; }\n    #chat_box { padding-bottom: 91px; }\n\n    #user { width: 100%; }\n    #message { width: 80%; }\n  }\n\n  @media(max-width: 400px) {\n    #footer { height: 135px; }\n    #chat_box { padding-bottom: 135px; }\n\n    #message { width: 100%; }\n    #send_btn {\n      position: relative;\n      margin-top: 3px;\n      width: 100%;\n    }\n  }\n</style>\n    \n    \n    \n  <div id=\"wrapper\">\n    <div id=\"chat_box\" class=\"content\"></div>\n\n    <div id=\"footer\">\n      <div class=\"content\">\n        <input type=\"text\" id=\"user\" placeholder=\"Who are you?\" />\n        <input type=\"text\" id=\"message\" placeholder=\"What do you want to say?\" />\n        <input type=\"button\" id=\"send_btn\" value=\"Send\" onclick=\"sendMessage()\">\n      </div>\n    </div>\n  </div>\n</body>\n\n\n\n\n","x":288.5170669555664,"y":774.8351821899414,"wires":[["9372b0b1.d92db"]]},{"id":"9372b0b1.d92db","type":"http response","z":"cd10f797.653218","name":"","x":431.5170669555664,"y":774.8351821899414,"wires":[]},{"id":"545dbcd.4d90e44","type":"websocket-listener","path":"/ws/chat","wholemsg":"false"}]
Advertisement
Add Comment
Please, Sign In to add comment