Hello to all,
I'm having a brain meltdown since I have a code to send error messages, I want to receive a message after 3 errors, so I introduced a counter and a filter.
It warns when I have 3 error but not when I stop having error, but if I force it in the counter inject buttons it works fine. Can someone please explain me of how it work in one way and not in the other?
Cheers
[
{
"id": "2f1d5163f620e4e4",
"type": "function",
"z": "395651665a2c113d",
"name": "clear counter",
"func": "msg.reset = true;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 850,
"y": 440,
"wires": [
[
"f971d755bff2fc42"
]
]
},
{
"id": "bb1c363d264036b0",
"type": "inject",
"z": "395651665a2c113d",
"name": "",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 650,
"y": 440,
"wires": [
[
"2f1d5163f620e4e4"
]
]
},
{
"id": "baa08b80827e14d8",
"type": "function",
"z": "395651665a2c113d",
"name": "inccounter",
"func": "msg.increment = 1;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 850,
"y": 400,
"wires": [
[
"f971d755bff2fc42"
]
]
},
{
"id": "1ad9cd8083c9deb9",
"type": "inject",
"z": "395651665a2c113d",
"name": "",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 650,
"y": 400,
"wires": [
[
"baa08b80827e14d8"
]
]
},
{
"id": "d06e756b50182275",
"type": "counter",
"z": "395651665a2c113d",
"name": "",
"init": "0",
"step": 1,
"lower": "",
"upper": "",
"mode": "increment",
"outputs": 1,
"x": 1060,
"y": 420,
"wires": [
[
"adcd6e4aca0a6848",
"97afb36c2599eece"
]
]
},
{
"id": "428b0112708bac30",
"type": "debug",
"z": "395651665a2c113d",
"name": "message",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "topic",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1900,
"y": 420,
"wires": []
},
{
"id": "1d40fb8f00d8c675",
"type": "function",
"z": "395651665a2c113d",
"name": "Config. Messages",
"func": "if (msg.CommError == 0)\n{\n msg.topic = 'Commm Error Restored';\n msg.payload = 'The comunication is restored';\n}\nif (msg.CommError == 1 )\n{\n msg.topic = 'Commm Error DOWN';\n msg.payload = 'The comunication is DOWN since ';\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1690,
"y": 420,
"wires": [
[
"428b0112708bac30"
]
]
},
{
"id": "97afb36c2599eece",
"type": "function",
"z": "395651665a2c113d",
"name": "Errors > 2",
"func": "//ALTERAR NOME CONTADOR(msg.error != 'Error: Timed out' || msg.error == 'Error: Client Not Ready To Read At State reconnecting' )\n\nif (msg.count > 1 )\n{\n msg.CommError = 1;\n}\nelse\n{\n msg.CommError = 0;\n} \n\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1240,
"y": 420,
"wires": [
[
"5c06ed3d6c4764f9",
"c2088301799b0f41"
]
],
"icon": "node-red/alert.svg"
},
{
"id": "c2088301799b0f41",
"type": "debug",
"z": "395651665a2c113d",
"name": "CommError",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1410,
"y": 480,
"wires": []
},
{
"id": "adcd6e4aca0a6848",
"type": "debug",
"z": "395651665a2c113d",
"name": "count",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1210,
"y": 480,
"wires": []
},
{
"id": "5c06ed3d6c4764f9",
"type": "rbe",
"z": "395651665a2c113d",
"name": "report-by-exception",
"func": "rbei",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "CommError",
"topi": "topic",
"x": 1450,
"y": 420,
"wires": [
[
"1d40fb8f00d8c675"
]
]
},
{
"id": "67dc3acdbce1e9f7",
"type": "inject",
"z": "395651665a2c113d",
"name": "count = 0",
"props": [
{
"p": "count",
"v": "0",
"vt": "num"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 1040,
"y": 340,
"wires": [
[
"97afb36c2599eece"
]
]
},
{
"id": "4707e2c1178e5160",
"type": "inject",
"z": "395651665a2c113d",
"name": "count = 3",
"props": [
{
"p": "count",
"v": "3",
"vt": "num"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 1040,
"y": 300,
"wires": [
[
"97afb36c2599eece"
]
]
},
{
"id": "f971d755bff2fc42",
"type": "junction",
"z": "395651665a2c113d",
"x": 980,
"y": 420,
"wires": [
[
"d06e756b50182275"
]
]
}
]