將RFID感應記錄 儲存於DataBase上及Line Notify上
[
{
"id": "6725046c.914358",
"type": "mqtt in",
"z": "bc8649ea.abc108",
"name": "MQTT",
"topic": "alex9ufo/outTopic/RFID/json",
"qos": "2",
"datatype": "auto",
"broker": "2071d72e.140ab8",
"x": 130,
"y": 180,
"wires": [
[
"e38548f3.2887c8",
"8ea91e3f.2c5c1",
"6cff9373.69879",
"991ae1d6.fab0c",
"6206a6c3.58201c"
]
]
},
{
"id": "69463aa.990c804",
"type": "mqtt out",
"z": "bc8649ea.abc108",
"name": "",
"topic": "alex9ufo/inTopic",
"qos": "1",
"retain": "false",
"broker": "2071d72e.140ab8",
"x": 540,
"y": 620,
"wires": []
},
{
"id": "335a27f.1407018",
"type": "ui_button",
"z": "bc8649ea.abc108",
"name": "",
"group": "54d05f53.b0203",
"order": 0,
"width": "4",
"height": "4",
"passthru": false,
"label": "on_LED",
"color": "white",
"bgcolor": "",
"icon": "fa-circle",
"payload": "#on",
"payloadType": "str",
"topic": "",
"x": 140,
"y": 600,
"wires": [
[
"69463aa.990c804",
"d78467e4.9e179",
"9ef07336.74c3c",
"9ae25ee.d07bd2"
]
]
},
{
"id": "c346b40e.8003b",
"type": "ui_button",
"z": "bc8649ea.abc108",
"name": "",
"group": "54d05f53.b0203",
"order": 0,
"width": "4",
"height": "4",
"passthru": false,
"label": "off_LED",
"color": "black",
"bgcolor": "",
"icon": "fa-circle-o",
"payload": "#off",
"payloadType": "str",
"topic": "",
"x": 140,
"y": 700,
"wires": [
[
"69463aa.990c804",
"d78467e4.9e179",
"9ae25ee.d07bd2",
"9ef07336.74c3c"
]
]
},
{
"id": "d78467e4.9e179",
"type": "debug",
"z": "bc8649ea.abc108",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 550,
"y": 680,
"wires": []
},
{
"id": "468f948a.73d72",
"type": "ui_button",
"z": "bc8649ea.abc108",
"name": "",
"group": "54d05f53.b0203",
"order": 0,
"width": "4",
"height": "4",
"passthru": false,
"label": "flash_LED",
"color": "black",
"bgcolor": "",
"icon": "fa-circle-o",
"payload": "#flash",
"payloadType": "str",
"topic": "",
"x": 150,
"y": 804,
"wires": [
[
"69463aa.990c804",
"d78467e4.9e179",
"9ae25ee.d07bd2",
"9ef07336.74c3c"
]
]
},
{
"id": "e38548f3.2887c8",
"type": "function",
"z": "bc8649ea.abc108",
"name": "json+時分秒",
"func": "//var date = new Date().toLocaleString();\nvar date = new Date();\n\nvar h = 8+ date.getHours();\nvar m = date.getMinutes();\nvar s = date.getSeconds();\nif(h<10){\n h = '0'+h;\n}\nif(m<10){\n m = '0' + m;\n}\nif(s<10){\n s = '0' + s;\n}\nmsg.payload = 'Time:(' + h + ':' + m + ':' + s + ')'+ msg.payload ;\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 330,
"y": 80,
"wires": [
[
"bd2a69f5.4b5928"
]
]
},
{
"id": "8ea91e3f.2c5c1",
"type": "switch",
"z": "bc8649ea.abc108",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "Alex9ufo",
"vt": "str"
},
{
"t": "cont",
"v": "RaspberryPi",
"vt": "str"
},
{
"t": "empty"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 290,
"y": 180,
"wires": [
[
"539807da.b0d368",
"4d5b3b35.720cdc"
],
[
"539807da.b0d368",
"de57b410.711c9"
],
[
"539807da.b0d368",
"27375244.95a736"
]
]
},
{
"id": "539807da.b0d368",
"type": "debug",
"z": "bc8649ea.abc108",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 470,
"y": 160,
"wires": []
},
{
"id": "6b4ebb94.a6cd98",
"type": "ui_audio",
"z": "bc8649ea.abc108",
"name": "",
"group": "54d05f53.b0203",
"voice": "en-US",
"always": "",
"x": 900,
"y": 240,
"wires": []
},
{
"id": "a8cb4759.4de458",
"type": "ui_audio",
"z": "bc8649ea.abc108",
"name": "",
"group": "54d05f53.b0203",
"voice": "en-US",
"always": "",
"x": 620,
"y": 800,
"wires": []
},
{
"id": "9ef07336.74c3c",
"type": "function",
"z": "bc8649ea.abc108",
"name": "Format timestamp",
"func": "var date = new Date();\nvar h = 8+ date.getHours();\nvar m = date.getMinutes();\nvar s = date.getSeconds();\nif(h<10){\n h = '0'+h;\n}\nif(m<10){\n m = '0' + m;\n}\nif(s<10){\n s = '0' + s;\n}\nmsg.payload = msg.payload + ' --> Time:(' + h + ':' + m + ':' + s + ')' ;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 450,
"y": 740,
"wires": [
[
"5b2d87f3.06919"
]
]
},
{
"id": "77528385.4c63b4",
"type": "debug",
"z": "bc8649ea.abc108",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 530,
"y": 360,
"wires": []
},
{
"id": "844f8bb2.481158",
"type": "inject",
"z": "bc8649ea.abc108",
"name": "CREATE DB",
"topic": "CREATE TABLE RFIDtable( id INT PRIMARY KEY NOT NULL, currenttime TEXT , uidname TEXT)",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 230,
"y": 460,
"wires": [
[
"f848bb96.505d48"
]
]
},
{
"id": "9ae25ee.d07bd2",
"type": "ui_text_input",
"z": "bc8649ea.abc108",
"name": "",
"label": "",
"group": "54d05f53.b0203",
"order": 9,
"width": "12",
"height": "2",
"passthru": true,
"mode": "text",
"delay": "0",
"topic": "",
"x": 440,
"y": 804,
"wires": [
[
"a8cb4759.4de458",
"4db6e8c9.ebb5d"
]
]
},
{
"id": "bac428d9.44b9e8",
"type": "ui_text_input",
"z": "bc8649ea.abc108",
"name": "",
"label": "",
"group": "54d05f53.b0203",
"order": 9,
"width": "12",
"height": "1",
"passthru": true,
"mode": "text",
"delay": "0",
"topic": "",
"x": 720,
"y": 240,
"wires": [
[
"6b4ebb94.a6cd98",
"ad826444.eb5f8"
]
]
},
{
"id": "ad826444.eb5f8",
"type": "delay",
"z": "bc8649ea.abc108",
"name": "",
"pauseType": "delay",
"timeout": "80",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 690,
"y": 320,
"wires": [
[
"1a1afdc3.ff113a"
]
]
},
{
"id": "1a1afdc3.ff113a",
"type": "function",
"z": "bc8649ea.abc108",
"name": "Check Text",
"func": "text=msg.payload;\nif(text !== \"\"){\n msg.payload = \"\";\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"x": 850,
"y": 320,
"wires": [
[
"bac428d9.44b9e8"
]
]
},
{
"id": "4db6e8c9.ebb5d",
"type": "delay",
"z": "bc8649ea.abc108",
"name": "",
"pauseType": "delay",
"timeout": "80",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 370,
"y": 860,
"wires": [
[
"824fac6e.2ee458"
]
]
},
{
"id": "824fac6e.2ee458",
"type": "function",
"z": "bc8649ea.abc108",
"name": "Check Text",
"func": "text=msg.payload;\nif(text !== \"\"){\n msg.payload = \"\";\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 860,
"wires": [
[
"9ae25ee.d07bd2"
]
]
},
{
"id": "b433cfda.9f63",
"type": "ui_button",
"z": "bc8649ea.abc108",
"name": "",
"group": "54d05f53.b0203",
"order": 0,
"width": "12",
"height": "2",
"passthru": false,
"label": "Testing......",
"color": "white",
"bgcolor": "",
"icon": "fa-circle",
"payload": "Testing",
"payloadType": "str",
"topic": "",
"x": 470,
"y": 320,
"wires": [
[
"bac428d9.44b9e8"
]
]
},
{
"id": "7dfb5af7.d623d4",
"type": "ui_template",
"z": "bc8649ea.abc108",
"group": "54d05f53.b0203",
"name": "",
"order": 0,
"width": "15",
"height": "10",
"format": "<table style=\"width:100%\">\n <tr>\n <th>Index</th> \n <th>Date</th> \n <th>RFID</th>\n </tr>\n <tr ng-repeat=\"x in msg.payload | limitTo:100\">\n <td>{{$index}}</td>\n <td>{{msg.payload[$index].currenttime}}</td>\n <td>{{msg.payload[$index].uidname}}</td> \n </tr>\n</table>",
"storeOutMessages": true,
"fwdInMessages": true,
"templateScope": "local",
"x": 680,
"y": 420,
"wires": [
[]
]
},
{
"id": "bd2a69f5.4b5928",
"type": "ui_text",
"z": "bc8649ea.abc108",
"group": "54d05f53.b0203",
"order": 0,
"width": "0",
"height": "0",
"name": "",
"label": "MQTT_send_Message",
"format": "{{msg.payload}}",
"layout": "row-left",
"x": 540,
"y": 80,
"wires": []
},
{
"id": "69cbb656.cccc",
"type": "function",
"z": "bc8649ea.abc108",
"name": "INSERT",
"func": "msg.topic = \"INSERT INTO RFIDtable (id,currenttime, uidname) VALUES (?,?,?)\";\n\n\nvar date = new Date();\n\nvar h = 8+ date.getHours();\n\nvar m = date.getMinutes();\n\nvar s = date.getSeconds();\n\nif(h<10)\n{\n \n h = '0'+h;\n\n}\n\nif(m<10)\n{\n \n m = '0' + m;\n\n}\n\nif(s<10)\n{\n \n s = '0' + s;\n\n}\n\nvar hms= h + ':' + m + ':' + s ;\nvar id= Date.now() ;\n\nmsg.payload = [id ,hms, msg.payload];\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 380,
"y": 360,
"wires": [
[
"77528385.4c63b4",
"f848bb96.505d48"
]
]
},
{
"id": "27375244.95a736",
"type": "function",
"z": "bc8649ea.abc108",
"name": "不合法卡片",
"func": "msg.payload = 'illegal Card'\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 470,
"y": 280,
"wires": [
[
"bac428d9.44b9e8"
]
]
},
{
"id": "26d4ef0f.ee0f78",
"type": "inject",
"z": "bc8649ea.abc108",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 280,
"y": 280,
"wires": [
[
"27375244.95a736"
]
]
},
{
"id": "de57b410.711c9",
"type": "function",
"z": "bc8649ea.abc108",
"name": "RaspberryPi卡片",
"func": "msg.payload = 'RaspberryPi Card'\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 490,
"y": 240,
"wires": [
[
"bac428d9.44b9e8"
]
]
},
{
"id": "4d5b3b35.720cdc",
"type": "function",
"z": "bc8649ea.abc108",
"name": "Alex9ufo卡片",
"func": "msg.payload = 'Alex9ufo Card'\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 470,
"y": 200,
"wires": [
[
"bac428d9.44b9e8"
]
]
},
{
"id": "5b2d87f3.06919",
"type": "function",
"z": "bc8649ea.abc108",
"name": "Set Line API ",
"func": "msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer cEI4hx24xyopKGAArgZcKJNHE1V7KeeIi4Lzny3dDNO'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 630,
"y": 740,
"wires": [
[
"41bd1482.4acb14"
]
]
},
{
"id": "41bd1482.4acb14",
"type": "http request",
"z": "bc8649ea.abc108",
"name": "",
"method": "POST",
"ret": "txt",
"url": "https://notify-api.line.me/api/notify",
"tls": "",
"x": 790,
"y": 740,
"wires": [
[
"41011fee.7f9f48"
]
]
},
{
"id": "41011fee.7f9f48",
"type": "debug",
"z": "bc8649ea.abc108",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 950,
"y": 740,
"wires": []
},
{
"id": "6206a6c3.58201c",
"type": "debug",
"z": "bc8649ea.abc108",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 330,
"y": 40,
"wires": []
},
{
"id": "6cff9373.69879",
"type": "json",
"z": "bc8649ea.abc108",
"name": "",
"property": "payload",
"action": "str",
"pretty": false,
"x": 210,
"y": 360,
"wires": [
[
"69cbb656.cccc"
]
]
},
{
"id": "7e4a1fdb.70db6c",
"type": "ui_button",
"z": "bc8649ea.abc108",
"name": "",
"group": "54d05f53.b0203",
"order": 10,
"width": "4",
"height": "4",
"passthru": false,
"label": "View Data",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "SELECT * FROM RFIDtable ORDER BY id DESC LIMIT 100;",
"x": 400,
"y": 500,
"wires": [
[
"f848bb96.505d48"
]
]
},
{
"id": "991ae1d6.fab0c",
"type": "function",
"z": "bc8649ea.abc108",
"name": "Format timestamp",
"func": "var date = new Date();\nvar h = 8+ date.getHours();\nvar m = date.getMinutes();\nvar s = date.getSeconds();\nif(h<10){\n h = '0'+h;\n}\nif(m<10){\n m = '0' + m;\n}\nif(s<10){\n s = '0' + s;\n}\nmsg.payload = msg.payload + ' --> Time:(' + h + ':' + m + ':' + s + ')' ;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 350,
"y": 120,
"wires": [
[
"275fd776.28cd08"
]
]
},
{
"id": "275fd776.28cd08",
"type": "function",
"z": "bc8649ea.abc108",
"name": "Set Line API ",
"func": "msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer cEI4hx24xyopKGAArgZcKJNHE1V7KeeIi4Lzny3dDNO'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 120,
"wires": [
[
"b5e9dc82.b827a"
]
]
},
{
"id": "b5e9dc82.b827a",
"type": "http request",
"z": "bc8649ea.abc108",
"name": "",
"method": "POST",
"ret": "txt",
"url": "https://notify-api.line.me/api/notify",
"tls": "",
"x": 690,
"y": 120,
"wires": [
[
"826c8303.bfd01"
]
]
},
{
"id": "826c8303.bfd01",
"type": "debug",
"z": "bc8649ea.abc108",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 850,
"y": 120,
"wires": []
},
{
"id": "ae33306a.d5d51",
"type": "comment",
"z": "bc8649ea.abc108",
"name": "CREATE TABLE RFIDtable",
"info": "CREATE TABLE RFIDtable( id INT PRIMARY KEY NOT NULL, currenttime TEXT , rfid TEXT)",
"x": 210,
"y": 500,
"wires": []
},
{
"id": "1abae79e.ae9764",
"type": "ui_button",
"z": "bc8649ea.abc108",
"name": "Alex9ufo",
"group": "54d05f53.b0203",
"order": 2,
"width": "4",
"height": "4",
"passthru": false,
"label": "手動插入測試資料",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "{\"RFIDNo\":\"Alex9ufo測試\"}",
"payloadType": "json",
"topic": "",
"x": 560,
"y": 500,
"wires": [
[
"75b01ea3.2a3a9"
]
]
},
{
"id": "75b01ea3.2a3a9",
"type": "mqtt out",
"z": "bc8649ea.abc108",
"name": "",
"topic": "alex9ufo/outTopic/RFID/json",
"qos": "",
"retain": "",
"broker": "2071d72e.140ab8",
"x": 780,
"y": 500,
"wires": []
},
{
"id": "3259bfa7.87607c",
"type": "ui_button",
"z": "bc8649ea.abc108",
"name": "",
"group": "54d05f53.b0203",
"order": 11,
"width": "4",
"height": "4",
"passthru": false,
"label": "建立資料庫(只能執行一次)",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "",
"payloadType": "str",
"topic": "CREATE TABLE RFIDtable( id INT PRIMARY KEY NOT NULL, currenttime TEXT , uidname TEXT)",
"x": 240,
"y": 420,
"wires": [
[
"f848bb96.505d48"
]
]
},
{
"id": "f848bb96.505d48",
"type": "litedb",
"z": "bc8649ea.abc108",
"name": "RFID",
"x": 530,
"y": 420,
"wires": [
[
"7dfb5af7.d623d4"
]
]
},
{
"id": "2071d72e.140ab8",
"type": "mqtt-broker",
"broker": "broker.mqtt-dashboard.com",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": 15,
"cleansession": true,
"birthQos": "0",
"willQos": "0"
},
{
"id": "54d05f53.b0203",
"type": "ui_group",
"z": "",
"name": "Control led ESP8266 (ESP32)",
"tab": "e6e7f124.a59e4",
"order": 1,
"disp": true,
"width": "15",
"collapse": false
},
{
"id": "e6e7f124.a59e4",
"type": "ui_tab",
"z": "",
"name": "RFID",
"icon": "dashboard",
"order": 1
}
]
沒有留言:
張貼留言