Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

740 lines (739 sloc) 22 KB
[
{
"id": "dbab9424.ebe0f8",
"type": "tab",
"label": "グラフ表示と制御",
"disabled": false,
"info": "本フローはsakura.ioハンズオンで利用する、Arduino Unoと温湿度センサ(HDC1000 or SHT31)を用いたグラフ表示とTwitter連携を試すものです。\n\n■グラフ表示&SNS投稿\n\nsakura.ioのWebSocket(`wss://api.sakura.io/ws/v1/.....`)サービスから送信されたJSONデータを用いてダッシュボード上にグラフを描画します。\nまた、グラフは`http://<IPアドレス>:<指定したWeb UIポート番号>/ui/`で確認することができます。\n\nオプションとして、Twittter IDを設定することで温度情報(Channel0)を取り出し、Twitterにメッセージを投稿します。\n\n以下2点を設定しデプロイすることで動作します。\n\n1. sakuraio_in(WebSocket-inノード)\n\n sakura.ioコンパネで確認できるWebSocketのURL(`wss://api.sakura.io/ws/v1/.....`)を設定します。\n\n2. Tweet(Twitterノード)\n\n  Ch0(temp)_parseとtrigger 1hrをドラッグアンドドロップで接続します。\n\n 認証を行いTwitterのアカウントを連携します。(鍵アカウントでの動作は確認していません)\n \n■デバイス制御\n\nダッシュボード上のボタンを押下することで、モジュールIDで指定したデバイスに制御用のJSONデータを生成し送信します。\n\n以下2点を設定しデプロイすることで動作します。\n\n1. moduleID_set(functionノード)\n\n sakura.ioコンパネで確認できるID(`uXXXXXXXXXXXX`)を設定します。\n \n2. sakuraio_out(WebSocket-outノード)\n\n sakura.ioコンパネで確認できるWebSocketのURL(`wss://api.sakura.io/ws/v1/.....`)を設定します。\n\n\n> [sakura.io コントロールパネル](https://secure.sakura.ad.jp/iot/)\n\n> [利用Arduinoスケッチ1(HDC1000利用時)](https://github.com/sakuraio/handson-sample/blob/master/arduino/basic-HDC1000-with-LED.ino)\n\n> [利用Arduinoスケッチ2(SHT31利用時)](https://github.com/sakuraio/handson-sample/blob/master/arduino/basic-SHT31-with-LED.ino)\n\n> [参考ハンズオン資料](https://speakerdeck.com/sakuraiot/sakuraio-handson-part1)"
},
{
"id": "6aa91ec7.7c76a",
"type": "websocket in",
"z": "dbab9424.ebe0f8",
"name": "sakuraio_in",
"server": "",
"client": "3efc4ee6.d6fc42",
"x": 110,
"y": 80,
"wires": [
[
"4c824085.9e118",
"5d198923.69a608"
]
]
},
{
"id": "4c824085.9e118",
"type": "json",
"z": "dbab9424.ebe0f8",
"name": "String→Object",
"pretty": false,
"x": 340,
"y": 80,
"wires": [
[
"c909773.594cd88"
]
]
},
{
"id": "c909773.594cd88",
"type": "switch",
"z": "dbab9424.ebe0f8",
"name": "Type_Check",
"property": "payload.type",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "channels",
"vt": "str"
}
],
"checkall": "true",
"outputs": 1,
"x": 150,
"y": 280,
"wires": [
[
"a557a3ec.c13b4",
"9fc7185e.35b118"
]
]
},
{
"id": "a557a3ec.c13b4",
"type": "function",
"z": "dbab9424.ebe0f8",
"name": "Ch0(temp)_parse",
"func": "msg.payload = Math.round(msg.payload.payload.channels[0].value*10)/10;return msg;",
"outputs": 1,
"noerr": 0,
"x": 410,
"y": 200,
"wires": [
[
"8d91e8af.9d0858",
"d8ec6c7a.f841d",
"57c78451.2c0b9c"
]
]
},
{
"id": "d8ec6c7a.f841d",
"type": "ui_chart",
"z": "dbab9424.ebe0f8",
"name": "Temp_chart",
"group": "4b67594d.a5b328",
"order": 2,
"width": "8",
"height": "5",
"label": "温度 (10分)",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "0",
"ymax": "40",
"removeOlder": "10",
"removeOlderPoints": "",
"removeOlderUnit": "60",
"cutout": 0,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"useOldStyle": true,
"x": 610,
"y": 200,
"wires": [
[],
[]
]
},
{
"id": "8d91e8af.9d0858",
"type": "ui_gauge",
"z": "dbab9424.ebe0f8",
"name": "Temp_gauge",
"group": "4b67594d.a5b328",
"order": 1,
"width": "8",
"height": "5",
"gtype": "gage",
"title": "現在の温度",
"label": "",
"format": "{{value}}",
"min": 0,
"max": "40",
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "30",
"seg2": "32",
"x": 610,
"y": 160,
"wires": []
},
{
"id": "9fc7185e.35b118",
"type": "function",
"z": "dbab9424.ebe0f8",
"name": "Ch1(humi)_parse",
"func": "msg.payload = Math.round(msg.payload.payload.channels[1].value*10)/10;return msg;",
"outputs": 1,
"noerr": 0,
"x": 410,
"y": 360,
"wires": [
[
"24faa6d4.b9547a",
"22b7968a.bfd7ea",
"43cd4220.bc135c"
]
]
},
{
"id": "b512a0b2.e4466",
"type": "debug",
"z": "dbab9424.ebe0f8",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 1170,
"y": 120,
"wires": []
},
{
"id": "94666103.72d45",
"type": "function",
"z": "dbab9424.ebe0f8",
"name": "Message",
"func": "msg.payload = `さくらインターネットのハンズオンで温度情報を取得中!ただ今の現地温度は${msg.payload}度だよ。資料は http://bit.ly/hosap101 です!今後ともよろしくお願いします! #sakuraio #さくらインターネット`;return msg;",
"outputs": 1,
"noerr": 0,
"x": 1000,
"y": 80,
"wires": [
[
"4876bcac.e67d94",
"b512a0b2.e4466"
]
]
},
{
"id": "134295dc.5808da",
"type": "trigger",
"z": "dbab9424.ebe0f8",
"op1": "",
"op2": "",
"op1type": "pay",
"op2type": "nul",
"duration": "1",
"extend": false,
"units": "hr",
"reset": "",
"bytopic": "all",
"name": "",
"x": 830,
"y": 80,
"wires": [
[
"94666103.72d45"
]
]
},
{
"id": "4876bcac.e67d94",
"type": "twitter out",
"z": "dbab9424.ebe0f8",
"twitter": "",
"name": "Tweet",
"x": 1150,
"y": 80,
"wires": []
},
{
"id": "24faa6d4.b9547a",
"type": "ui_gauge",
"z": "dbab9424.ebe0f8",
"name": "Humi_gauge",
"group": "4a6401b3.8bf5",
"order": 0,
"width": "8",
"height": "5",
"gtype": "gage",
"title": "現在の湿度",
"label": "%",
"format": "{{value}}",
"min": 0,
"max": "100",
"colors": [
"#ca3838",
"#00b500",
"#0000d2"
],
"seg1": "30",
"seg2": "70",
"x": 610,
"y": 320,
"wires": []
},
{
"id": "22b7968a.bfd7ea",
"type": "ui_chart",
"z": "dbab9424.ebe0f8",
"name": "Humi_chart",
"group": "4a6401b3.8bf5",
"order": 0,
"width": "8",
"height": "5",
"label": "湿度 (10分)",
"chartType": "line",
"legend": "false",
"xformat": "HH:mm:ss",
"interpolate": "linear",
"nodata": "",
"dot": false,
"ymin": "0",
"ymax": "100",
"removeOlder": "10",
"removeOlderPoints": "",
"removeOlderUnit": "60",
"cutout": 0,
"colors": [
"#1f77b4",
"#aec7e8",
"#ff7f0e",
"#2ca02c",
"#98df8a",
"#d62728",
"#ff9896",
"#9467bd",
"#c5b0d5"
],
"useOldStyle": true,
"x": 610,
"y": 360,
"wires": [
[],
[]
]
},
{
"id": "7566db0f.ffb034",
"type": "comment",
"z": "dbab9424.ebe0f8",
"name": "ダッシュボード画面でのグラフ表示",
"info": "",
"x": 160,
"y": 40,
"wires": []
},
{
"id": "60fdce21.fe051",
"type": "ui_button",
"z": "dbab9424.ebe0f8",
"name": "LED_RED_on",
"group": "600c4eb9.9c1f6",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"label": "RED on",
"color": "",
"bgcolor": "red",
"icon": "",
"payload": "redon",
"payloadType": "global",
"topic": "",
"x": 140,
"y": 700,
"wires": [
[
"d3a687cd.558e78",
"e80f109f.d3463"
]
]
},
{
"id": "d3a687cd.558e78",
"type": "websocket out",
"z": "dbab9424.ebe0f8",
"name": "sakuraio_out",
"server": "",
"client": "fc59ee64.e5928",
"x": 590,
"y": 700,
"wires": []
},
{
"id": "e80f109f.d3463",
"type": "debug",
"z": "dbab9424.ebe0f8",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 590,
"y": 760,
"wires": []
},
{
"id": "798124d1.aa107c",
"type": "ui_button",
"z": "dbab9424.ebe0f8",
"name": "LED_GREEN_on",
"group": "600c4eb9.9c1f6",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"label": "GREEN on",
"color": "",
"bgcolor": "limegreen",
"icon": "",
"payload": "greenon",
"payloadType": "global",
"topic": "",
"x": 150,
"y": 740,
"wires": [
[
"d3a687cd.558e78",
"e80f109f.d3463"
]
]
},
{
"id": "5948cfa.78f5f3",
"type": "ui_button",
"z": "dbab9424.ebe0f8",
"name": "LED_BLUE_on",
"group": "600c4eb9.9c1f6",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"label": "BLUE on",
"color": "",
"bgcolor": "blue",
"icon": "",
"payload": "blueon",
"payloadType": "global",
"topic": "",
"x": 140,
"y": 780,
"wires": [
[
"d3a687cd.558e78",
"e80f109f.d3463"
]
]
},
{
"id": "4f3b1581.101c7c",
"type": "ui_button",
"z": "dbab9424.ebe0f8",
"name": "LED_RED_off",
"group": "600c4eb9.9c1f6",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"label": "RED off",
"color": "",
"bgcolor": "tan",
"icon": "",
"payload": "redoff",
"payloadType": "global",
"topic": "",
"x": 140,
"y": 820,
"wires": [
[
"d3a687cd.558e78",
"e80f109f.d3463"
]
]
},
{
"id": "3a993dd3.775602",
"type": "ui_button",
"z": "dbab9424.ebe0f8",
"name": "LED_GREEN_off",
"group": "600c4eb9.9c1f6",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"label": "GREEN off",
"color": "",
"bgcolor": "darkseagreen",
"icon": "",
"payload": "greenoff",
"payloadType": "global",
"topic": "",
"x": 150,
"y": 860,
"wires": [
[
"d3a687cd.558e78",
"e80f109f.d3463"
]
]
},
{
"id": "77f4aa.c867bb58",
"type": "ui_button",
"z": "dbab9424.ebe0f8",
"name": "LED_BLUE_off",
"group": "600c4eb9.9c1f6",
"order": 0,
"width": 0,
"height": 0,
"passthru": true,
"label": "BLUE off",
"color": "",
"bgcolor": "lightskyblue",
"icon": "",
"payload": "blueoff",
"payloadType": "global",
"topic": "",
"x": 140,
"y": 900,
"wires": [
[
"d3a687cd.558e78",
"e80f109f.d3463"
]
]
},
{
"id": "acb60037.ede2f",
"type": "ui_button",
"z": "dbab9424.ebe0f8",
"name": "LED_ALL_on",
"group": "600c4eb9.9c1f6",
"order": 0,
"width": "4",
"height": "2",
"passthru": true,
"label": "ALL on",
"color": "",
"bgcolor": "gold",
"icon": "",
"payload": "allon",
"payloadType": "global",
"topic": "",
"x": 130,
"y": 940,
"wires": [
[
"d3a687cd.558e78",
"e80f109f.d3463"
]
]
},
{
"id": "e5288cf.1ac757",
"type": "ui_button",
"z": "dbab9424.ebe0f8",
"name": "LED_ALL_off",
"group": "600c4eb9.9c1f6",
"order": 0,
"width": "4",
"height": "2",
"passthru": true,
"label": "ALL off",
"color": "",
"bgcolor": "gray",
"icon": "",
"payload": "alloff",
"payloadType": "global",
"topic": "",
"x": 130,
"y": 980,
"wires": [
[
"d3a687cd.558e78",
"e80f109f.d3463"
]
]
},
{
"id": "d7fbab5.140a658",
"type": "comment",
"z": "dbab9424.ebe0f8",
"name": "デバイス制御(動作部分)",
"info": "",
"x": 130,
"y": 660,
"wires": []
},
{
"id": "bd363cb.334d5c",
"type": "comment",
"z": "dbab9424.ebe0f8",
"name": "デバイス制御(モジュールID指定と制御用JSONデータの定義)",
"info": "",
"x": 250,
"y": 460,
"wires": []
},
{
"id": "d4648be7.6583c8",
"type": "function",
"z": "dbab9424.ebe0f8",
"name": "moduleID_set",
"func": "//context.global.moduleに制御対象のモジュールIDを指定\ncontext.global.module = \"%%moduleID%%\";\n\nmsg.payload = context.global.module;\nreturn msg;",
"outputs": "1",
"noerr": 0,
"x": 340,
"y": 560,
"wires": [
[
"dbf4b9be.223bc8"
]
]
},
{
"id": "6cf4cf3e.f2fb6",
"type": "inject",
"z": "dbab9424.ebe0f8",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": true,
"x": 130,
"y": 560,
"wires": [
[
"d4648be7.6583c8"
]
]
},
{
"id": "282a8aa0.b8d5d6",
"type": "debug",
"z": "dbab9424.ebe0f8",
"name": "",
"active": false,
"console": "false",
"complete": "payload",
"x": 770,
"y": 560,
"wires": []
},
{
"id": "dbf4b9be.223bc8",
"type": "function",
"z": "dbab9424.ebe0f8",
"name": "JSON_set",
"func": "context.global.redon = {\n \"module\": context.global.module,\n \"type\": \"channels\",\n \"payload\": {\n \"channels\": [\n {\n \"channel\": 0,\n \"type\": \"I\",\n \"value\": 1\n }\n ]\n }\n};\ncontext.global.greenon = {\n \"module\": context.global.module,\n \"type\": \"channels\",\n \"payload\": {\n \"channels\": [\n {\n \"channel\": 1,\n \"type\": \"I\",\n \"value\": 1\n }\n ]\n }\n};\ncontext.global.blueon = {\n \"module\": context.global.module,\n \"type\": \"channels\",\n \"payload\": {\n \"channels\": [\n {\n \"channel\": 2,\n \"type\": \"I\",\n \"value\": 1\n }\n ]\n }\n};\ncontext.global.redoff = {\n \"module\": context.global.module,\n \"type\": \"channels\",\n \"payload\": {\n \"channels\": [\n {\n \"channel\": 0,\n \"type\": \"I\",\n \"value\": 0\n }\n ]\n }\n};\ncontext.global.greenoff = {\n \"module\": context.global.module,\n \"type\": \"channels\",\n \"payload\": {\n \"channels\": [\n {\n \"channel\": 1,\n \"type\": \"I\",\n \"value\": 0\n }\n ]\n }\n};\ncontext.global.blueoff = {\n \"module\": context.global.module,\n \"type\": \"channels\",\n \"payload\": {\n \"channels\": [\n {\n \"channel\": 2,\n \"type\": \"I\",\n \"value\": 0\n }\n ]\n }\n};\ncontext.global.allon = {\n \"module\": context.global.module,\n \"type\": \"channels\",\n \"payload\": {\n \"channels\": [\n {\n \"channel\": 0,\n \"type\": \"I\",\n \"value\": 1\n },\n {\n \"channel\": 1,\n \"type\": \"I\",\n \"value\": 1\n },\n {\n \"channel\": 2,\n \"type\": \"I\",\n \"value\": 1\n }\n ]\n }\n};\ncontext.global.alloff = {\n \"module\": context.global.module,\n \"type\": \"channels\",\n \"payload\": {\n \"channels\": [\n {\n \"channel\": 0,\n \"type\": \"I\",\n \"value\": 0\n },\n {\n \"channel\": 1,\n \"type\": \"I\",\n \"value\": 0\n },\n {\n \"channel\": 2,\n \"type\": \"I\",\n \"value\": 0\n }\n ]\n }\n};\n\nreturn [\n {payload:context.global.redon},\n {payload:context.global.greenon},\n {payload:context.global.blueon},\n {payload:context.global.redoff},\n {payload:context.global.greenoff},\n {payload:context.global.blueoff},\n {payload:context.global.allon},\n {payload:context.global.alloff}\n];",
"outputs": "8",
"noerr": 0,
"x": 590,
"y": 560,
"wires": [
[
"282a8aa0.b8d5d6"
],
[
"282a8aa0.b8d5d6"
],
[
"282a8aa0.b8d5d6"
],
[
"282a8aa0.b8d5d6"
],
[
"282a8aa0.b8d5d6"
],
[
"282a8aa0.b8d5d6"
],
[
"282a8aa0.b8d5d6"
],
[
"282a8aa0.b8d5d6"
]
]
},
{
"id": "43cd4220.bc135c",
"type": "debug",
"z": "dbab9424.ebe0f8",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 610,
"y": 400,
"wires": []
},
{
"id": "57c78451.2c0b9c",
"type": "debug",
"z": "dbab9424.ebe0f8",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 610,
"y": 240,
"wires": []
},
{
"id": "5d198923.69a608",
"type": "debug",
"z": "dbab9424.ebe0f8",
"name": "",
"active": false,
"console": "false",
"complete": "false",
"x": 190,
"y": 140,
"wires": []
},
{
"id": "c4a42a0f.f49748",
"type": "comment",
"z": "dbab9424.ebe0f8",
"name": "【オプション】SNS投稿",
"info": "",
"x": 830,
"y": 40,
"wires": []
},
{
"id": "3efc4ee6.d6fc42",
"type": "websocket-client",
"z": "",
"path": "wss://api.sakura.io/ws/v1/",
"tls": "",
"wholemsg": "false"
},
{
"id": "4b67594d.a5b328",
"type": "ui_group",
"z": "",
"name": "温度",
"tab": "34242c41.c92474",
"order": 1,
"disp": true,
"width": "8"
},
{
"id": "4a6401b3.8bf5",
"type": "ui_group",
"z": "",
"name": "湿度",
"tab": "34242c41.c92474",
"order": 2,
"disp": true,
"width": "8"
},
{
"id": "600c4eb9.9c1f6",
"type": "ui_group",
"z": "",
"name": "Control",
"tab": "34242c41.c92474",
"disp": true,
"width": "4"
},
{
"id": "fc59ee64.e5928",
"type": "websocket-client",
"z": "",
"path": "wss://api.sakura.io/ws/v1/",
"tls": "",
"wholemsg": "false"
},
{
"id": "34242c41.c92474",
"type": "ui_tab",
"z": "",
"name": "Handson",
"icon": "dashboard",
"order": 1
}
]
You can’t perform that action at this time.