[
{
"id": "a0a22bbe.4dd42",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "4189be61.b54dd",
"type": "sqlite",
"z": "a0a22bbe.4dd42",
"mydb": "ebf455b5.0e09e",
"sqlquery": "msg.topic",
"sql": "SELECT * FROM NCS WHERE Person_ID='{{payload}}';",
"name": "SQLITE3",
"x": 760,
"y": 220,
"wires": [
[
"81f4171d.a3c57"
]
]
},
{
"id": "81f4171d.a3c57",
"type": "switch",
"z": "a0a22bbe.4dd42",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "empty"
},
{
"t": "nempty"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 850,
"y": 300,
"wires": [
[
"b6e09667.cfd1f8"
],
[
"47c73500.14fd6c"
]
]
},
{
"id": "b6e09667.cfd1f8",
"type": "change",
"z": "a0a22bbe.4dd42",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "CR_FAIL",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1040,
"y": 220,
"wires": [
[
"b4f536b1.835ee",
"c857818d.fa3bd"
]
]
},
{
"id": "47c73500.14fd6c",
"type": "change",
"z": "a0a22bbe.4dd42",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "CR_SUCCESS",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1040,
"y": 360,
"wires": [
[
"b4c18fb9.b990e8",
"c857818d.fa3bd",
"743e1ca5.336ef4"
]
]
},
{
"id": "4629413e.f8d6f",
"type": "function",
"z": "a0a22bbe.4dd42",
"name": "",
"func": "let newMsg = {};\nnewMsg.topic = `SELECT Person_ID FROM NCS_DATABASE WHERE Person_ID='${msg.payload}'`;\nreturn newMsg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 520,
"y": 220,
"wires": [
[
"4189be61.b54dd"
]
]
},
{
"id": "950a518e.f68788",
"type": "function",
"z": "a0a22bbe.4dd42",
"name": "id no space ",
"func": "msg.payload = msg.payload.replace(/\\s/g, '')\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 290,
"y": 220,
"wires": [
[
"7cc57b61.7cddbc"
]
]
},
{
"id": "e1c813c6.492a18",
"type": "function",
"z": "a0a22bbe.4dd42",
"name": "function2",
"func": "let newMsg1 = {};\nnewMsg1.topic = `SELECT Fob_Tag_ID FROM NCS_DATABASE WHERE Fob_Tag_ID ='${msg.payload}'`;\nreturn newMsg1;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 520,
"y": 280,
"wires": [
[
"4189be61.b54dd"
]
]
},
{
"id": "42ce4ee7.c335d8",
"type": "function",
"z": "a0a22bbe.4dd42",
"name": "tagid no space ",
"func": "msg.payload = msg.payload.replace(/\\s/g, '')\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 300,
"y": 280,
"wires": [
[
"ce2e3f7f.05cd6"
]
]
},
{
"id": "8b7358f2.2eb348",
"type": "mqtt in",
"z": "a0a22bbe.4dd42",
"name": "",
"topic": "FOB_and_TAG",
"qos": "1",
"datatype": "buffer",
"broker": "2b0fd3c9.2369b4",
"x": 120,
"y": 360,
"wires": [
[]
]
},
{
"id": "b4c18fb9.b990e8",
"type": "change",
"z": "a0a22bbe.4dd42",
"name": "",
"rules": [
{
"t": "set",
"p": "id",
"pt": "msg",
"to": "id",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1330,
"y": 360,
"wires": [
[
"cf6f5371.cdfa7"
]
]
},
{
"id": "2cd6eb05.9d3e94",
"type": "sqlite",
"z": "a0a22bbe.4dd42",
"mydb": "ebf455b5.0e09e",
"sqlquery": "msg.topic",
"sql": "UPDATE NCS_DATABASE\nSET Status='{{payload}}'\nWHERE Person_ID='{{id}}';",
"name": "SQLITE3",
"x": 1920,
"y": 360,
"wires": [
[
"b6956c2d.14843"
]
]
},
{
"id": "7cc57b61.7cddbc",
"type": "change",
"z": "a0a22bbe.4dd42",
"name": "",
"rules": [
{
"t": "set",
"p": "id",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 160,
"wires": [
[
"4629413e.f8d6f"
]
]
},
{
"id": "ce2e3f7f.05cd6",
"type": "change",
"z": "a0a22bbe.4dd42",
"name": "",
"rules": [
{
"t": "set",
"p": "id",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 340,
"wires": [
[
"e1c813c6.492a18"
]
]
},
{
"id": "56217bc.1faf604",
"type": "debug",
"z": "a0a22bbe.4dd42",
"name": "NCS_debug1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1780,
"y": 280,
"wires": []
},
{
"id": "c0ab02b9.8d1e1",
"type": "debug",
"z": "a0a22bbe.4dd42",
"name": "NCS_debug11",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 2300,
"y": 620,
"wires": []
},
{
"id": "b6956c2d.14843",
"type": "debug",
"z": "a0a22bbe.4dd42",
"name": "DR1OFF debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 2000,
"y": 460,
"wires": []
},
{
"id": "b4f536b1.835ee",
"type": "debug",
"z": "a0a22bbe.4dd42",
"name": " debug",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1470,
"y": 220,
"wires": []
},
{
"id": "743e1ca5.336ef4",
"type": "debug",
"z": "a0a22bbe.4dd42",
"name": " debug2",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1500,
"y": 260,
"wires": []
},
{
"id": "cf6f5371.cdfa7",
"type": "function",
"z": "a0a22bbe.4dd42",
"name": "",
"func": "\nlet newMsg1 = {};\nnewMsg1.topic = `UPDATE NCS_DATABASE SET Status='DR1 ON' WHERE Person_ID='${msg.id}'`;\nreturn newMsg1;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1580,
"y": 360,
"wires": [
[
"2cd6eb05.9d3e94",
"56217bc.1faf604"
]
]
},
{
"id": "c857818d.fa3bd",
"type": "mqtt out",
"z": "a0a22bbe.4dd42",
"name": "",
"topic": "MATCH",
"qos": "1",
"retain": "true",
"broker": "2b0fd3c9.2369b4",
"x": 1260,
"y": 280,
"wires": []
},
{
"id": "af79011e.e6c558",
"type": "mqtt in",
"z": "a0a22bbe.4dd42",
"name": "",
"topic": "FOB",
"qos": "1",
"datatype": "auto",
"broker": "2b0fd3c9.2369b4",
"x": 90,
"y": 220,
"wires": [
[
"950a518e.f68788"
]
]
},
{
"id": "1df40781.f708b8",
"type": "mqtt in",
"z": "a0a22bbe.4dd42",
"name": "",
"topic": "TRADE",
"qos": "1",
"datatype": "auto",
"broker": "2b0fd3c9.2369b4",
"x": 90,
"y": 280,
"wires": [
[
"42ce4ee7.c335d8"
]
]
},
{
"id": "ebf455b5.0e09e",
"type": "sqlitedb",
"z": "",
"db": "/home/shipra/Documents/NCS_Projects/IOT/NCS_API/NCS.db",
"mode": "RWC"
},
{
"id": "2b0fd3c9.2369b4",
"type": "mqtt-broker",
"z": "",
"name": "",
"broker": "tcp://mqtt.eclipse.org",
"port": "1883",
"clientid": "NCS_Client_03",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": false,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]