Hello!
Testing this it looks like the reset properly happens when a message under the threshold is received,
however;
The fact that the trigger node reset itself once it sends the delayed message, will trigger another message when the sensor reports more values above 10 during 21 minutes.
To me, the logic seems more like:
"as long as the sensor reports values above x, send a notification every y minutes"
In case you want a "latch", to only send once after 21 minutes and only send again after a reported value below the threshold has been reported, I think more advanced logic with function nodes are required.
I made a flow that demonstrates this:
[
{
"id": "dadce3dbbd68230f",
"type": "switch",
"z": "e530c6e5cc985538",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "10",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 250,
"y": 100,
"wires": [
[
"c6bc8657215f251a"
],
[
"cc709b296f661d90"
]
]
},
{
"id": "45fcf65755cf40a0",
"type": "debug",
"z": "e530c6e5cc985538",
"name": "Current behavior",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 790,
"y": 100,
"wires": []
},
{
"id": "c6bc8657215f251a",
"type": "trigger",
"z": "e530c6e5cc985538",
"name": "",
"op1": "",
"op2": "",
"op1type": "nul",
"op2type": "pay",
"duration": "5",
"extend": false,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 600,
"y": 100,
"wires": [
[
"45fcf65755cf40a0"
]
]
},
{
"id": "cc709b296f661d90",
"type": "change",
"z": "e530c6e5cc985538",
"name": "",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 420,
"y": 140,
"wires": [
[
"c6bc8657215f251a"
]
]
},
{
"id": "b1a081abd823998d",
"type": "inject",
"z": "e530c6e5cc985538",
"name": "above",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "20",
"payloadType": "jsonata",
"x": 110,
"y": 80,
"wires": [
[
"dadce3dbbd68230f"
]
]
},
{
"id": "2d8ecba8dc757325",
"type": "inject",
"z": "e530c6e5cc985538",
"name": "under",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "5",
"payloadType": "num",
"x": 110,
"y": 120,
"wires": [
[
"dadce3dbbd68230f"
]
]
},
{
"id": "5e77ce50ae55fd5e",
"type": "function",
"z": "e530c6e5cc985538",
"name": "Message latch",
"func": "let threshold = 10;\n\nlet triggered = context.get('triggered');\n\nif(msg.payload > threshold) {\n if(triggered) {\n return null;\n }\n context.set('triggered', true);\n return msg;\n} else {\n if(triggered) {\n context.set('triggered', false);\n }\n return {reset: true}\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 300,
"y": 280,
"wires": [
[
"bd22a87a7e800dbb"
]
]
},
{
"id": "d00d0beca616143d",
"type": "inject",
"z": "e530c6e5cc985538",
"name": "above",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "20",
"payloadType": "jsonata",
"x": 110,
"y": 260,
"wires": [
[
"5e77ce50ae55fd5e"
]
]
},
{
"id": "42c68813fbd20108",
"type": "inject",
"z": "e530c6e5cc985538",
"name": "under",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "5",
"payloadType": "num",
"x": 110,
"y": 300,
"wires": [
[
"5e77ce50ae55fd5e"
]
]
},
{
"id": "c5c95c3ec4d97d6f",
"type": "debug",
"z": "e530c6e5cc985538",
"name": "Latch behavior",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 280,
"wires": []
},
{
"id": "bd22a87a7e800dbb",
"type": "trigger",
"z": "e530c6e5cc985538",
"name": "",
"op1": "",
"op2": "",
"op1type": "nul",
"op2type": "pay",
"duration": "5",
"extend": false,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 460,
"y": 280,
"wires": [
[
"c5c95c3ec4d97d6f"
]
]
},
{
"id": "9f6682a9ef615034",
"type": "comment",
"z": "e530c6e5cc985538",
"name": "Current behavior",
"info": "Keep pressing the above button for more than 5 seconds will result in multiple triggers ",
"x": 120,
"y": 40,
"wires": []
},
{
"id": "5a7111e1965a82de",
"type": "comment",
"z": "e530c6e5cc985538",
"name": "Latch behavior",
"info": "Keep pressing the above button for more than 5 seconds will only yield one trigger.\n\nIn order to get a new trigger, the under button has to be pressed.",
"x": 120,
"y": 220,
"wires": []
}
]
This will send the first payload that had value > 10 and block the rest until a message with value <= 10 is received