作業2-2 RFID + (Node-Red & SQLite )+Line Notify
系統圖
Arduino 程式 (ESP32)
https://alex9ufoexploer.blogspot.com/2023/11/2-arduino-2-1-2-2-2-3.html
1) Node-Red 匯入程式後 先將所有的 SQLite 節點 資料庫儲存 路徑位置修改
目前 資料庫位置 C:\Users\User\.node-red\EX2_1.db
2) 資料庫 動作前須 先 建立 資料庫
CREATE TABLE RFIDtable(id INTEGER PRIMARY KEY AUTOINCREMENT, uidname TEXT, currentdate DATE, currenttime TIME)
//CREATE TABLE "RFIDtable" (
// "id" INT NOT NULL,
// "uidname" TEXT,
// "currentdate" DATE,
// "currenttime" TIME
// PRIMARY KEY("id")
//);
msg.topic = "CREATE TABLE RFIDtable(id INTEGER PRIMARY KEY AUTOINCREMENT, uidname TEXT, currentdate DATE, currenttime TIME)";
return msg;
3) 新增模式 或 比對模式的切換 (新增卡片號碼 到資料庫 或 此卡號是否存在於資料庫內)
4) 人工比對資料庫
先輸入 UID 然後按 比對資料庫 即可查詢 資料庫內的UID 是否存在
5) 刪除一筆資料
先輸入id 然後在按 刪除一筆資料
var del_id = flow.get("idtemp");
msg.topic = "DELETE FROM RFIDtable WHERE id= ($del_id) " ;
msg.payload = [del_id]
return msg;
CREATE TABLE "RFIDtable" (
"id" INT NOT NULL,
"uidname" TEXT,
"currentdate" DATE,
"currenttime" TIME
PRIMARY KEY("id")
);
所以 要 重新建立資料庫 才能工作 但是 刪除所有資料 不需要 重新建立資料庫
名稱 |
內容 |
|
刪除資料庫 |
//DROP TABLE RFIDtable msg.topic = "DROP TABLE
RFIDtable"; return msg; |
|
刪除所有資料 |
//DELETE from RFIDtable msg.topic = "DELETE from
RFIDtable"; return msg; |
|
7) 切換到 比對模式下 (或是 查詢模式)
只要將卡片 放到MFRC522 Reader 感應即可
Node-Red 畫面
Node-Red程式
[{"id":"c8fa9aba54ec59a7","type":"comment","z":"e580410840f1977a","name":"TABLE RFIDtable","info":"\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\nmsg.topic = \"CREATE TABLE RFIDtable(id INTEGER PRIMARY KEY AUTOINCREMENT, uidname TEXT, currentdate DATE, currenttime TIME)\";\nreturn msg;\n","x":100,"y":40,"wires":[]},{"id":"2352757b9ad7a413","type":"comment","z":"e580410840f1977a","name":"資料庫位置 C:\\Users\\User\\.node-red\\EX2_1.db","info":"","x":200,"y":80,"wires":[]},{"id":"17d9e4c5934e31b7","type":"ui_button","z":"e580410840f1977a","name":"","group":"a453c7f575918a4b","order":5,"width":3,"height":1,"passthru":false,"label":"建立資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"建立資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":90,"y":160,"wires":[["cec32cf0368a6160","428e36df65bc5d0a"]]},{"id":"3d724916bd0ceba4","type":"ui_button","z":"e580410840f1977a","name":"","group":"a453c7f575918a4b","order":7,"width":6,"height":2,"passthru":false,"label":"檢視資料庫資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"檢視資料","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":600,"wires":[["e8144d7ac36b0990","0dd203ac6f82de67","9546f9f1689f5abd"]]},{"id":"27863b993a3145c5","type":"ui_button","z":"e580410840f1977a","name":"","group":"a453c7f575918a4b","order":4,"width":3,"height":1,"passthru":false,"label":"刪除所有資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除所有資料","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":860,"wires":[["f61681d67b6dfe6a","e95a213155e2ae2a"]]},{"id":"cec32cf0368a6160","type":"function","z":"e580410840f1977a","name":"CREATE DATABASE","func":"\n\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\nmsg.topic = \"CREATE TABLE RFIDtable(id INTEGER PRIMARY KEY AUTOINCREMENT, uidname TEXT, currentdate DATE, currenttime TIME)\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":160,"wires":[["2e873ff2215f1627"]]},{"id":"7c7b9e7101f99220","type":"debug","z":"e580410840f1977a","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":200,"wires":[]},{"id":"e910514ceb4ba7e4","type":"function","z":"e580410840f1977a","name":"INSERT","func":"var Today = new Date();\nvar yyyy = Today.getFullYear(); //年\nvar MM = Today.getMonth()+1; //月\nvar dd = Today.getDate(); //日\nvar h = Today.getHours(); //時\nvar m = Today.getMinutes(); //分\nvar s = Today.getSeconds(); //秒\nif(MM<10)\n{\n MM = '0'+MM;\n}\n\nif(dd<10)\n{\n dd = '0'+dd;\n}\n\nif(h<10)\n{\n h = '0'+h;\n}\n\nif(m<10)\n{\n m = '0' + m;\n}\n\nif(s<10)\n{\n s = '0' + s;\n}\nvar var_date = yyyy+'/'+MM+'/'+dd;\nvar var_time = h+':'+m+':'+s;\n\nvar myRFID = flow.get('uid_temp');\n\n\nmsg.topic = \"INSERT INTO RFIDtable ( uidname , currentdate, currenttime ) VALUES ($myRFID, $var_date , $var_time ) \" ;\nmsg.payload = [myRFID, var_date , var_time ]\nreturn msg;\n\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":240,"wires":[["aceead06c5b4ca45","86a04561d5732afb"]]},{"id":"348309a2df49a7ef","type":"function","z":"e580410840f1977a","name":"刪除所有資料","func":"//DELETE from RFIDtable\nmsg.topic = \"DELETE from RFIDtable\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":880,"wires":[["e6c4b8d95973acc8"]]},{"id":"833f20c5fc9f52d1","type":"ui_button","z":"e580410840f1977a","name":"","group":"a453c7f575918a4b","order":3,"width":3,"height":1,"passthru":false,"label":"刪除資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":90,"y":960,"wires":[["1a152f4111ca81fd","fde22b8219ffe519"]]},{"id":"497862d022c85886","type":"function","z":"e580410840f1977a","name":"刪除資料庫","func":"//DROP TABLE RFIDtable\nmsg.topic = \"DROP TABLE RFIDtable\";\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":960,"wires":[["ac223b4659d0d7a2"]]},{"id":"e89357f8bf99cd44","type":"debug","z":"e580410840f1977a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":940,"wires":[]},{"id":"9546f9f1689f5abd","type":"function","z":"e580410840f1977a","name":"檢視資料","func":"\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\n\n//SELECT * FROM RFIDtable ORDER BY id DESC LIMIT 50;\n\nmsg.topic = \"SELECT * FROM RFIDtable ORDER BY id DESC LIMIT 50\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":740,"y":600,"wires":[["8caa729f53e3c29e","db51b6b49c4a1679"]]},{"id":"3d80f359772cdc4d","type":"function","z":"e580410840f1977a","name":"SELECT ALL","func":"var del_idtemp=msg.payload;\nflow.set(\"idtemp\", del_idtemp);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":800,"wires":[["d5f8a1e57c898a43"]]},{"id":"a1fd876403c87858","type":"function","z":"e580410840f1977a","name":"確認 刪除","func":"var del_id = flow.get(\"idtemp\");\n\n\nmsg.topic = \"DELETE FROM RFIDtable WHERE id= ($del_id) \" ;\nmsg.payload = [del_id]\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":740,"wires":[["2d75f8fea620282a"]]},{"id":"e4f6b192711dfd88","type":"ui_numeric","z":"e580410840f1977a","name":"","label":"刪除的database_id","tooltip":"","group":"cb0bc005d4b7ba13","order":7,"width":6,"height":1,"wrap":true,"passthru":true,"topic":"topic","topicType":"msg","format":"{{value}}","min":"1","max":"1000","step":1,"className":"","x":110,"y":800,"wires":[["3d80f359772cdc4d"]]},{"id":"4a31b56857469cb3","type":"ui_button","z":"e580410840f1977a","name":"","group":"a453c7f575918a4b","order":2,"width":3,"height":1,"passthru":false,"label":"刪除一筆資料","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"刪除一筆資料","payloadType":"str","topic":"topic","topicType":"msg","x":100,"y":660,"wires":[["e8144d7ac36b0990","4c4db109522eac71"]]},{"id":"d5f8a1e57c898a43","type":"debug","z":"e580410840f1977a","name":"debug 220","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":800,"wires":[]},{"id":"11c055356daf7399","type":"mqtt in","z":"e580410840f1977a","name":"新增 RFID","topic":"alex9ufo/esp32/RFID","qos":"2","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":80,"y":240,"wires":[["37adfdab4179c6ec","da9dbbae9a283e86"]]},{"id":"8367becc9030c688","type":"ui_audio","z":"e580410840f1977a","name":"","group":"26e583680376a2a5","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":540,"y":400,"wires":[]},{"id":"7c2bb0d4fded7582","type":"function","z":"e580410840f1977a","name":"function ","func":"var temp= msg.payload;\nmsg.payload= \"新增一筆資料\" + temp;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":320,"wires":[["8367becc9030c688","9b70f6dff006576b","9a309750a2b99426"]]},{"id":"e8144d7ac36b0990","type":"ui_audio","z":"e580410840f1977a","name":"","group":"26e583680376a2a5","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":300,"y":640,"wires":[]},{"id":"428e36df65bc5d0a","type":"ui_audio","z":"e580410840f1977a","name":"","group":"26e583680376a2a5","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":240,"y":120,"wires":[]},{"id":"7096b1af0ab0453a","type":"function","z":"e580410840f1977a","name":"比對 function","func":"//SELECT trackid,name FROM \ttracks WHERE name LIKE 'Wild%'\n//Query\n//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\n//msg.topic = \"DELETE FROM RFIDtable WHERE id= ($del_id) \" ;\n\nvar query_uid = flow.get(\"uidtemp\");\nmsg.topic = \"SELECT id,uidname , currentdate,currenttime FROM RFIDtable WHERE uidname LIKE ($query_uid) \";\nmsg.payload = [query_uid]\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":1040,"wires":[["0f892898e5714cfd"]]},{"id":"cc68c73eaae49094","type":"ui_button","z":"e580410840f1977a","name":"","group":"a453c7f575918a4b","order":1,"width":3,"height":1,"passthru":false,"label":"比對資料庫","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"比對資料庫","payloadType":"str","topic":"topic","topicType":"msg","x":90,"y":1040,"wires":[["7096b1af0ab0453a","1a152f4111ca81fd","58c96606c91c99d4"]]},{"id":"5ff1d4ea2ba3eb45","type":"function","z":"e580410840f1977a","name":"SELECT ALL","func":"var query_uidtemp=msg.payload;\nflow.set(\"uidtemp\", query_uidtemp);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":440,"wires":[["8beff873e7fdd27c","7dc7477636c7404f"]]},{"id":"5544fea4843e4855","type":"ui_text_input","z":"e580410840f1977a","name":"","label":"手動查詢資料的uidname","tooltip":"","group":"cb0bc005d4b7ba13","order":4,"width":3,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":330,"y":500,"wires":[["5ff1d4ea2ba3eb45"]]},{"id":"b2fe54510f211974","type":"function","z":"e580410840f1977a","name":"function ","func":"var query=msg.payload;\n\nif (query== '1' )\n msg.payload='Query';\nelse\n msg.payload='NotQuery';\n\nflow.set(\"query_temp\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":1460,"wires":[["6c6b07341575977b","af59cbe0eeea4671"]]},{"id":"8b510792cab8c4c8","type":"ui_switch","z":"e580410840f1977a","name":"","label":"新增模式 /自動比對模式 ","tooltip":"","group":"cb0bc005d4b7ba13","order":1,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"s1","topicType":"str","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":270,"y":1460,"wires":[["b2fe54510f211974","a334729b99de6386","9a3042cad990b6e4"]]},{"id":"6c6b07341575977b","type":"debug","z":"e580410840f1977a","name":"debug 221","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":1440,"wires":[]},{"id":"573df0b38289efb2","type":"switch","z":"e580410840f1977a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Create","vt":"str"},{"t":"eq","v":"Query","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":130,"y":360,"wires":[["e910514ceb4ba7e4","7c2bb0d4fded7582"],["e73e704ab4e766ad"]]},{"id":"37adfdab4179c6ec","type":"function","z":"e580410840f1977a","name":"Query or Insert ","func":"var query = flow.get(\"query_temp\");\n\nflow.set(\"uid_temp\", msg.payload);\n\nif (query==='NotQuery')\n msg.payload='Create'\nelse\n msg.payload='Query'\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":240,"wires":[["573df0b38289efb2"]]},{"id":"af59cbe0eeea4671","type":"ui_audio","z":"e580410840f1977a","name":"","group":"26e583680376a2a5","voice":"Google US English","always":true,"x":680,"y":1480,"wires":[]},{"id":"8beff873e7fdd27c","type":"debug","z":"e580410840f1977a","name":"debug 222","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":460,"wires":[]},{"id":"7dc7477636c7404f","type":"ui_text","z":"e580410840f1977a","group":"cb0bc005d4b7ba13","order":8,"width":6,"height":1,"name":"","label":"自動感應RFID查詢的uid","format":"{{msg.payload}}","layout":"row-left","className":"","x":790,"y":360,"wires":[]},{"id":"eb435a5d96be0c13","type":"function","z":"e580410840f1977a","name":"function ","func":"//CREATE TABLE \"RFIDtable\" (\n//\t\"id\"\tINT NOT NULL,\n// \"uidname\" TEXT,\n// \"currentdate\" DATE, \n// \"currenttime\" TIME\n//\tPRIMARY KEY(\"id\")\n//);\n\n//msg.topic = \"INSERT INTO RFIDtable ( uidname , currentdate, currenttime ) VALUES ($myRFID, $var_date , $var_time ) \" ;\n//msg.payload = [myRFID, var_date , var_time ]\n//return msg;\n\n\nvar tmp=msg.payload;\nmsg.topic = \"select count( * ) as 總共有幾筆資料 from RFIDtable where uidname=($tmp)\";\nmsg.payload=[tmp];\nreturn msg;\n\n// select count( * ) as 總共有幾筆資料 from Customers where address='Japan'","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":1180,"wires":[["f815556e7bd20e4c"]]},{"id":"4ac1e40f5421fd71","type":"function","z":"e580410840f1977a","name":"function ","func":"var num=msg.payload[0].總共有幾筆資料;\nmsg.payload=num;\nreturn msg; \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":1180,"wires":[["9136307096e69bad","6206a4be4bb20775"]]},{"id":"0fa86f77787f9532","type":"ui_text","z":"e580410840f1977a","group":"cb0bc005d4b7ba13","order":6,"width":3,"height":1,"name":"","label":"查詢結果","format":"<font face='arial'><font size=3><font color={{fcolor}}>{{msg.payload}}","layout":"row-left","className":"","x":1040,"y":1240,"wires":[]},{"id":"cc84c8e5de754878","type":"ui_text","z":"e580410840f1977a","group":"cb0bc005d4b7ba13","order":5,"width":3,"height":1,"name":"","label":"查詢結果:筆數","format":"<font face='arial'><font size=6><font color={{fcolor}}>{{msg.payload}}","layout":"row-left","className":"","x":1060,"y":1180,"wires":[]},{"id":"edced61c20b76390","type":"mqtt in","z":"e580410840f1977a","name":"","topic":"alex9ufo/esp32/Starting","qos":"2","datatype":"auto-detect","broker":"841df58d.ee5e98","nl":false,"rap":true,"rh":0,"inputs":0,"x":120,"y":1300,"wires":[["693ab072c6384c5a","313bba70c138c36a"]]},{"id":"693ab072c6384c5a","type":"ui_audio","z":"e580410840f1977a","name":"","group":"26e583680376a2a5","voice":"Google US English","always":false,"x":320,"y":1340,"wires":[]},{"id":"9136307096e69bad","type":"change","z":"e580410840f1977a","name":"","rules":[{"t":"set","p":"fcolor","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":1180,"wires":[["cc84c8e5de754878"]]},{"id":"069bd252f7e422bd","type":"change","z":"e580410840f1977a","name":"","rules":[{"t":"set","p":"fcolor","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":1240,"wires":[["0fa86f77787f9532"]]},{"id":"58c96606c91c99d4","type":"function","z":"e580410840f1977a","name":"function","func":"\nvar a= flow.get(\"uidtemp\");\nmsg.payload=a;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":280,"y":1180,"wires":[["eb435a5d96be0c13"]]},{"id":"297871396face2a1","type":"ui_audio","z":"e580410840f1977a","name":"","group":"26e583680376a2a5","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":1040,"y":1280,"wires":[]},{"id":"ceac1b14fad49384","type":"delay","z":"e580410840f1977a","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":880,"y":1280,"wires":[["297871396face2a1"]]},{"id":"6206a4be4bb20775","type":"function","z":"e580410840f1977a","name":"function ","func":"var n=msg.payload;\n\nif (n>0)\n msg.payload='RFID符合';\nelse\n msg.payload='RFID錯誤';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":1240,"wires":[["ceac1b14fad49384","069bd252f7e422bd","b7aa65168b6f133d"]]},{"id":"9b70f6dff006576b","type":"function","z":"e580410840f1977a","name":"取得UID號碼","func":"var myRFID = flow.get('uid_temp');\nmsg.payload=myRFID;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":360,"wires":[["7dc7477636c7404f"]]},{"id":"1a152f4111ca81fd","type":"ui_audio","z":"e580410840f1977a","name":"","group":"26e583680376a2a5","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":240,"y":1000,"wires":[]},{"id":"f61681d67b6dfe6a","type":"ui_audio","z":"e580410840f1977a","name":"","group":"26e583680376a2a5","voice":"Microsoft Hanhan - Chinese (Traditional, Taiwan)","always":true,"x":300,"y":840,"wires":[]},{"id":"aceead06c5b4ca45","type":"function","z":"e580410840f1977a","name":"增加 日期 時間","func":"var ms1=msg.payload[0];\nvar ms2=msg.payload[1];\nvar ms3=msg.payload[2];\n\nmsg.payload=\"新增一筆:\"+ms1+\", 日期: \"+ms2+\", 時間:\"+ms3;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":280,"wires":[["193dbe1b059eeebb"]]},{"id":"193dbe1b059eeebb","type":"function","z":"e580410840f1977a","name":"Set Line API ","func":"msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer A4wwPNh2WqB7dlfeQyyIAwtggn1kfZSI5LkkCdia1gB'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;\n\n//oR7KdXvK1eobRr2sRRgsl4PMq23DjDlhfUs96SyUBZu","outputs":1,"noerr":0,"x":790,"y":280,"wires":[["c8ba1a37a7d21f76"]]},{"id":"c8ba1a37a7d21f76","type":"http request","z":"e580410840f1977a","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":940,"y":280,"wires":[["4b0f1f7f15c069df"]]},{"id":"4b0f1f7f15c069df","type":"debug","z":"e580410840f1977a","name":"debug 225","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1090,"y":280,"wires":[]},{"id":"4473e94ad686cd24","type":"comment","z":"e580410840f1977a","name":"Line Notify Message ","info":"","x":810,"y":320,"wires":[]},{"id":"45da028e5ff2187b","type":"function","z":"e580410840f1977a","name":"Set Line API ","func":"msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer A4wwPNh2WqB7dlfeQyyIAwtggn1kfZSI5LkkCdia1gB'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;\n\n//oR7KdXvK1eobRr2sRRgsl4PMq23DjDlhfUs96SyUBZu","outputs":1,"noerr":0,"x":870,"y":1380,"wires":[["18fc9ffb4c17305c"]]},{"id":"5981d7ab159d482c","type":"comment","z":"e580410840f1977a","name":"Line Notify Message ","info":"","x":1050,"y":1420,"wires":[]},{"id":"18fc9ffb4c17305c","type":"http request","z":"e580410840f1977a","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":1020,"y":1380,"wires":[["bfbd0054f0f82240"]]},{"id":"bfbd0054f0f82240","type":"debug","z":"e580410840f1977a","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1150,"y":1380,"wires":[]},{"id":"b7aa65168b6f133d","type":"function","z":"e580410840f1977a","name":"function","func":"\nvar a= flow.get(\"uidtemp\");\nvar b=msg.payload;\nmsg.payload=a+\"--->\"+b;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":700,"y":1340,"wires":[["45da028e5ff2187b","ec7c95943d3205b6"]]},{"id":"b821a2b279a4ae38","type":"ui_table","z":"e580410840f1977a","group":"26e583680376a2a5","name":"","order":1,"width":12,"height":11,"columns":[],"outputs":0,"cts":false,"x":1050,"y":600,"wires":[]},{"id":"70b242b47377c8fb","type":"inject","z":"e580410840f1977a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"0","payloadType":"str","x":90,"y":1460,"wires":[["8b510792cab8c4c8"]]},{"id":"a334729b99de6386","type":"change","z":"e580410840f1977a","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"查詢模式","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"0","fromt":"num","to":"新增模式","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1600,"wires":[["9f609962e464cb8c","960b814e224e0c5d"]]},{"id":"9f609962e464cb8c","type":"ui_text_input","z":"e580410840f1977a","name":"","label":"State:","tooltip":"","group":"cb0bc005d4b7ba13","order":3,"width":3,"height":1,"passthru":true,"mode":"text","delay":300,"topic":"","sendOnBlur":true,"className":"","topicType":"str","x":530,"y":1620,"wires":[[]]},{"id":"9a3042cad990b6e4","type":"debug","z":"e580410840f1977a","name":"debug ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":1520,"wires":[]},{"id":"53e87d564850e3d0","type":"inject","z":"e580410840f1977a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":480,"y":80,"wires":[["059e64992e70beee"]]},{"id":"059e64992e70beee","type":"function","z":"e580410840f1977a","name":"id SET ","func":"var del_idtemp=1;\nflow.set(\"idtemp\", del_idtemp);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":80,"wires":[[]]},{"id":"313bba70c138c36a","type":"ui_toast","z":"e580410840f1977a","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":350,"y":1300,"wires":[]},{"id":"960b814e224e0c5d","type":"ui_toast","z":"e580410840f1977a","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":570,"y":1580,"wires":[]},{"id":"e95a213155e2ae2a","type":"ui_toast","z":"e580410840f1977a","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":210,"y":900,"wires":[["2cdf9575d5c3ce4d"]]},{"id":"2cdf9575d5c3ce4d","type":"function","z":"e580410840f1977a","name":"OK or Cancel","func":"var topic=msg.payload;\nif (topic==\"\"){\n return [msg,null];\n \n}\nif (topic==\"Cancel\"){\n return [null,msg];\n \n}\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":900,"wires":[["348309a2df49a7ef"],[]]},{"id":"fde22b8219ffe519","type":"ui_toast","z":"e580410840f1977a","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":250,"y":960,"wires":[["5c5e97885157f4b4"]]},{"id":"5c5e97885157f4b4","type":"function","z":"e580410840f1977a","name":"OK or Cancel","func":"var topic=msg.payload;\nif (topic==\"\"){\n return [msg,null];\n \n}\nif (topic==\"Cancel\"){\n return [null,msg];\n \n}\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":960,"wires":[["497862d022c85886"],[]]},{"id":"4c4db109522eac71","type":"ui_toast","z":"e580410840f1977a","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"Cancel","raw":true,"className":"","topic":"","name":"","x":210,"y":740,"wires":[["29635cb1252e1e7b"]]},{"id":"29635cb1252e1e7b","type":"function","z":"e580410840f1977a","name":"OK or Cancel","func":"var topic=msg.payload;\nif (topic==\"\"){\n return [msg,null];\n \n}\nif (topic==\"Cancel\"){\n return [null,msg];\n \n}\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":380,"y":740,"wires":[["a1fd876403c87858"],[]]},{"id":"71e3c9e772097c69","type":"link out","z":"e580410840f1977a","name":"link out 41","mode":"link","links":["2b440998c35377bf"],"x":845,"y":880,"wires":[]},{"id":"2b440998c35377bf","type":"link in","z":"e580410840f1977a","name":"link in 39","links":["71e3c9e772097c69","e4de9ca1fd6f1ad2","70487decb239f3c4","ce142a687d0b79f1"],"x":635,"y":560,"wires":[["9546f9f1689f5abd"]]},{"id":"e4de9ca1fd6f1ad2","type":"link out","z":"e580410840f1977a","name":"link out 43","mode":"link","links":["2b440998c35377bf"],"x":855,"y":240,"wires":[]},{"id":"ecdb23d852e3fa7f","type":"ui_toast","z":"e580410840f1977a","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":1070,"y":1340,"wires":[]},{"id":"0dd203ac6f82de67","type":"ui_toast","z":"e580410840f1977a","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":310,"y":560,"wires":[]},{"id":"9a309750a2b99426","type":"ui_toast","z":"e580410840f1977a","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":570,"y":320,"wires":[]},{"id":"136b7f887c7ac8af","type":"debug","z":"e580410840f1977a","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":160,"wires":[]},{"id":"e73e704ab4e766ad","type":"function","z":"e580410840f1977a","name":"get UID","func":"\nvar a= flow.get(\"uid_temp\");\nmsg.payload=a;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":440,"wires":[["5ff1d4ea2ba3eb45","330ac65349eea739"]]},{"id":"ec7c95943d3205b6","type":"function","z":"e580410840f1977a","name":"function","func":"var b=msg.payload;\nmsg.payload=\"Line Notify --->\"+b;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":1340,"wires":[["ecdb23d852e3fa7f"]]},{"id":"da9dbbae9a283e86","type":"ui_toast","z":"e580410840f1977a","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"Cancel","raw":false,"className":"","topic":"","name":"","x":250,"y":200,"wires":[]},{"id":"330ac65349eea739","type":"link out","z":"e580410840f1977a","name":"link out 45","mode":"link","links":["7f20cbcaea30ce95"],"x":415,"y":420,"wires":[]},{"id":"7f20cbcaea30ce95","type":"link in","z":"e580410840f1977a","name":"link in 41","links":["330ac65349eea739"],"x":135,"y":1220,"wires":[["58c96606c91c99d4"]]},{"id":"ca9bc6e8a598b75d","type":"comment","z":"e580410840f1977a","name":"Set Default Value","info":"","x":480,"y":40,"wires":[]},{"id":"2e873ff2215f1627","type":"sqlite","z":"e580410840f1977a","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":540,"y":160,"wires":[["136b7f887c7ac8af"]]},{"id":"86a04561d5732afb","type":"sqlite","z":"e580410840f1977a","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":720,"y":240,"wires":[["e4de9ca1fd6f1ad2","7c7b9e7101f99220"]]},{"id":"8caa729f53e3c29e","type":"sqlite","z":"e580410840f1977a","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":880,"y":600,"wires":[["b821a2b279a4ae38"]]},{"id":"2d75f8fea620282a","type":"sqlite","z":"e580410840f1977a","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":680,"y":740,"wires":[["9546f9f1689f5abd"]]},{"id":"e6c4b8d95973acc8","type":"sqlite","z":"e580410840f1977a","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":720,"y":880,"wires":[["e89357f8bf99cd44","71e3c9e772097c69"]]},{"id":"ac223b4659d0d7a2","type":"sqlite","z":"e580410840f1977a","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":740,"y":960,"wires":[["e89357f8bf99cd44"]]},{"id":"0f892898e5714cfd","type":"sqlite","z":"e580410840f1977a","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":720,"y":1040,"wires":[["b821a2b279a4ae38"]]},{"id":"db51b6b49c4a1679","type":"debug","z":"e580410840f1977a","name":"debug 227","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":560,"wires":[]},{"id":"f815556e7bd20e4c","type":"sqlite","z":"e580410840f1977a","mydb":"f87c808cc786ae80","sqlquery":"msg.topic","sql":"","name":"RFID dB","x":560,"y":1180,"wires":[["4ac1e40f5421fd71"]]},{"id":"a453c7f575918a4b","type":"ui_group","name":"命命區","tab":"3113488b40e7e950","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"cb0bc005d4b7ba13","type":"ui_group","name":"新增或比對","tab":"3113488b40e7e950","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"841df58d.ee5e98","type":"mqtt-broker","name":"","broker":"broker.hivemq.com","port":"1883","clientid":"","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"26e583680376a2a5","type":"ui_group","name":"顯示區","tab":"3113488b40e7e950","order":2,"disp":true,"width":12,"collapse":false,"className":""},{"id":"f87c808cc786ae80","type":"sqlitedb","db":"C:\\Users\\User\\.node-red\\EX2_2.db","mode":"RWC"},{"id":"3113488b40e7e950","type":"ui_tab","name":"作業2-2","icon":"dashboard","order":90,"disabled":false,"hidden":false}]
8) Line Notify (需改成自己的權杖 不然我會收到各位的Line) 修改2處
沒有留言:
張貼留言