Hello!
I want to send tag data to API based on condition ..when the tag value changes from (true) to
(false) in device the API should send data .we should write a script for this configuration or there are any other way to solve this problem??
{
"id": "f3bf0ccb5a652f28",
"type": "change",
"z": "1934b69fd66fe8ff",
"name": "",
"rules": [
{
"t": "set",
"p": "Timestamp",
"pt": "msg",
"to": "$moment($now()).format(\"YYYY-MM-DD HH:mm\")\t",
"tot": "jsonata"
},
{
"t": "set",
"p": "headers.Content-Type",
"pt": "msg",
"to": "application/json",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1020,
"y": 280,
"wires": [
[
"424eb14a3cd5dff7",
"0ded6faf4af883f6"
]
]
},
{
"id": "424eb14a3cd5dff7",
"type": "debug",
"z": "1934b69fd66fe8ff",
"name": "Check msg.TagID and msg.dateTime ",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1310,
"y": 280,
"wires": []
},
{
"id": "d902e4f47b6a71a3",
"type": "function",
"z": "1934b69fd66fe8ff",
"name": "",
"func": "msg.payload={\n\"Machinekey\":1,\n\"Count\":1,\n\"Value\":msg.payload\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1000,
"y": 360,
"wires": [
[
"393ea5c67de87342",
"f6440b4e10076b01"
]
]
},
{
"id": "7001736f19b5dcf6",
"type": "change",
"z": "1934b69fd66fe8ff",
"name": "",
"rules": [
{
"t": "set",
"p": "Timestamp",
"pt": "msg",
"to": "$moment($now()).format(\"YYYY-MM-DD HH:mm\")\t",
"tot": "jsonata"
},
{
"t": "set",
"p": "headers.Content-Type",
"pt": "msg",
"to": "application/json",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1020,
"y": 440,
"wires": [
[
"f6440b4e10076b01",
"393ea5c67de87342"
]
]
},
{
"id": "393ea5c67de87342",
"type": "http request",
"z": "1934b69fd66fe8ff",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "http://192.168.1.189:1003/api/Home/AddMachineData?Machinekey={{MachineKey}}&Parameter&Count=7&Value=98&Timestamp={{Timestamp}}",
"tls": "",
"persist": true,
"proxy": "",
"authType": "bearer",
"senderr": false,
"x": 1190,
"y": 360,
"wires": [
[
"21aefa8841fc842d"
]
]
},
{
"id": "f6440b4e10076b01",
"type": "debug",
"z": "1934b69fd66fe8ff",
"name": "Check msg.TagID and msg.dateTime ",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1310,
"y": 440,
"wires": []
},
{
"id": "21aefa8841fc842d",
"type": "debug",
"z": "1934b69fd66fe8ff",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1370,
"y": 360,
"wires": []
},
{
"id": "8567d0a3e704bcf0",
"type": "switch",
"z": "1934b69fd66fe8ff",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "false"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 850,
"y": 400,
"wires": [
[
"d902e4f47b6a71a3",
"7001736f19b5dcf6"
]
]
}
]
post edited to add ``` around the code