I do have flow like this, I don't really remember why I put this, but I think it is related to my device got false positive from node-red, I admit that it happen because I don't really understand how mqtt and its qos works
[
{
"id": "0aeb209feaada50c",
"type": "mqtt in",
"z": "b89019e2f6e43ba2",
"name": "",
"topic": "resURL",
"qos": "1",
"datatype": "auto-detect",
"broker": "489be411582992b5",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 70,
"y": 600,
"wires": [
[
"51f435c5afc961a1",
"8fe535d9a6928f0c"
]
]
},
{
"id": "51f435c5afc961a1",
"type": "function",
"z": "b89019e2f6e43ba2",
"name": "function 104",
"func": "var mesej = msg.payload\n\nif(mesej == \"\"){\n msg.payload = \"\"\n return msg;\n} else if (mesej == \"Data Sudah Terupdate \"){\n flow.set(\"process\", 0)\n flow.set(\"statResURL\", 1)\n}else{\n flow.set(\"statResURL\", 1)\n}",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 250,
"y": 600,
"wires": [
[
"2ceef4b134da1581"
]
]
},
{
"id": "e69e7a9244ca6662",
"type": "mqtt out",
"z": "b89019e2f6e43ba2",
"name": "",
"topic": "resURL",
"qos": "1",
"retain": "true",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "489be411582992b5",
"x": 820,
"y": 600,
"wires": []
},
{
"id": "2ceef4b134da1581",
"type": "delay",
"z": "b89019e2f6e43ba2",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 420,
"y": 600,
"wires": [
[
"d754b67d59b10ace"
]
]
},
{
"id": "d754b67d59b10ace",
"type": "function",
"z": "b89019e2f6e43ba2",
"name": "function 122",
"func": "var pesan = msg.payload\nvar stat = flow.get(\"statResURL\") | 0\nif (stat == 1) {\n flow.set(\"statResURL\", 0)\n} else {\n msg.payload = pesan\n return msg;\n}",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 590,
"y": 600,
"wires": [
[
"e69e7a9244ca6662"
]
]
},
{
"id": "8fe535d9a6928f0c",
"type": "switch",
"z": "b89019e2f6e43ba2",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Data Sudah Terupdate ",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 240,
"y": 720,
"wires": [
[
"51ffbcf9ef3464d6"
]
]
},
{
"id": "51ffbcf9ef3464d6",
"type": "change",
"z": "b89019e2f6e43ba2",
"name": "",
"rules": [
{
"t": "set",
"p": "process",
"pt": "flow",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 720,
"wires": [
[]
]
},
{
"id": "489be411582992b5",
"type": "mqtt-broker",
"name": "Control Room",
"broker": "172.16.16.253",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
}
]