Hi.
I'm not quite understanding the question.
How good are you with programming/using Node-red?
Alas the only way I can see you doing it is with a function node and a bit of code.
Idea:
You have the normal input to the node and have a second input to cause the value to be captured.
I'm not sure if you hare using a dashboard or not. But I'm guessing you are.
But for the sake of keeping it simple I will only talk at the editor level.
The inject node would send a payload of HOLD. Given the other payloads are numbers.
Doing this here/now.
con
No, hang on.
I'll make the code in the editor and post.
const message = msg.payload
let hold = context.get("hold") || 0
// If `HOLD`
if (message == "HOLD")
{
context.set("hold",1)
return // Nothing more to do be hone here/now
}
if (hold == 1)
{
// `hold` is set.
context.set("store",msg.payload)
context.set("hold",0) // stop next message being storred too.
}
return msg
Thoughts.
Rather than context (nodal) make it flow context.
That way you can see the stored value from elsewhere.
Replace: context.set("store" with flow.set("store" for the value.
and context.set("hold" with flow.set("hold"
and context.get("hold" with flow.get("hold"
Then in another part of the flow, you can see the value and wipe the hold condition.
Example flow:
[{"id":"509552482ce62bd8","type":"function","z":"6cf51e98651df17b","name":"The magic happens here.","func":"const message = msg.payload\nlet hold = flow.get(\"hold\") || 0\n\n// If `HOLD`\nif (message == \"HOLD\")\n{\n flow.set(\"hold\",1)\n return // Nothing more to do be hone here/now\n}\n\nif (hold == 1)\n{\n // `hold` is set.\n flow.set(\"store\",msg.payload)\n flow.set(\"hold\",0) // stop next message being storred too.\n}\n\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2600,"y":4210,"wires":[["8c11f2103322c9cd"]]},{"id":"4f1ae4a73d6db203","type":"inject","z":"6cf51e98651df17b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2100,"y":4210,"wires":[["4f6b16abf4ef6dc4"]]},{"id":"4f6b16abf4ef6dc4","type":"function","z":"6cf51e98651df17b","name":"random vlue for testing","func":"const randomNumber = Math.floor(Math.random() * 10) + 1\nmsg.payload = randomNumber\n\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2290,"y":4210,"wires":[["509552482ce62bd8"]]},{"id":"c80e384d4cde4c9e","type":"inject","z":"6cf51e98651df17b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"HOLD","payloadType":"str","x":2340,"y":4150,"wires":[["509552482ce62bd8"]]},{"id":"f08a667949b8a286","type":"inject","z":"6cf51e98651df17b","name":"Read stored value","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":2130,"y":4330,"wires":[["5433167c824dd54f"]]},{"id":"5433167c824dd54f","type":"change","z":"6cf51e98651df17b","name":"get value","rules":[{"t":"set","p":"payload","pt":"msg","to":"store","tot":"flow"},{"t":"set","p":"hold","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":2330,"y":4330,"wires":[["eb35e83ef43ee6e6"]]},{"id":"eb35e83ef43ee6e6","type":"debug","z":"6cf51e98651df17b","name":"Look","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2540,"y":4330,"wires":[]},{"id":"8c11f2103322c9cd","type":"debug","z":"6cf51e98651df17b","name":"to Where ever","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2870,"y":4210,"wires":[]}]