Send information only by pressing a button "Speichern"

Dear Node-Red´s

I do have a problem to hand off informations only if a "Store" button is pressed. My flow looks like this:

[{"id":"46f3fadcb97268ab","type":"ui_button","z":"84622180359efd62","name":"Speichern","group":"7763f99169395494","order":13,"width":0,"height":0,"passthru":true,"label":"Speichern/store","tooltip":"Speichert die Daten in der Datenbank","color":"","bgcolor":"{{colour}}","icon":"","payload":"true","payloadType":"bool","topic":"payload","topicType":"msg","x":560,"y":880,"wires":[["56df29454df9d063"]]},{"id":"56df29454df9d063","type":"trigger","z":"84622180359efd62","name":"","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"1","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":800,"y":880,"wires":[["98e21e25054d9623"]]},{"id":"0e353c3e8a65bd44","type":"inject","z":"84622180359efd62","name":"Store","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":360,"y":880,"wires":[["46f3fadcb97268ab"]]},{"id":"9790e28241b2bd8d","type":"debug","z":"84622180359efd62","name":"store (true/false)","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1320,"y":880,"wires":},{"id":"98e21e25054d9623","type":"function","z":"84622180359efd62","name":"speichern","func":"var e=msg.payload;\nglobal.set("speichern", e) ; //Input in Variable speichern \nmsg.payload =e,"Speichern";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":1040,"y":880,"wires":[["9790e28241b2bd8d"]]},{"id":"138ea281f71d60a5","type":"function","z":"84622180359efd62","name":"Transfer info after "Speichern" is pressed","func":"// This node should send the input thrue if speichern is true \n\nif (global.get("speichern")==true) {\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":1040,"y":680,"wires":[["9a2743aac464f89e"]]},{"id":"9a2743aac464f89e","type":"debug","z":"84622180359efd62","name":"Speichern","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1320,"y":680,"wires":},{"id":"4858a82a295aa484","type":"ui_dropdown","z":"84622180359efd62","name":"Test input","label":"Test input","tooltip":"","place":"0","group":"7763f99169395494","order":6,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"0,0","value":"0,0","type":"str"},{"label":"0,1","value":"0,1","type":"str"},{"label":"0,5","value":"0,5","type":"str"},{"label":"1,0","value":"1,0","type":"str"},{"label":"5,0","value":"5,0","type":"str"}],"payload":"","topic":"Test","topicType":"str","x":520,"y":680,"wires":[["10a88fb2008e0ae3","138ea281f71d60a5"]]},{"id":"344c311e7f9cadfd","type":"inject","z":"84622180359efd62","name":"1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Pruefdruck","payload":"1,0","payloadType":"str","x":350,"y":720,"wires":[["4858a82a295aa484"]]},{"id":"1cc030a74f89eae7","type":"inject","z":"84622180359efd62","name":"5","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Pruefdruck","payload":"5,0","payloadType":"str","x":350,"y":760,"wires":[["4858a82a295aa484"]]},{"id":"06fbd0626802fa7a","type":"inject","z":"84622180359efd62","name":"0,5","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Pruefdruck","payload":"0,5","payloadType":"str","x":350,"y":680,"wires":[["4858a82a295aa484"]]},{"id":"0b10235f72d3629c","type":"inject","z":"84622180359efd62","name":"0,1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Pruefdruck","payload":"0,1","payloadType":"str","x":350,"y":640,"wires":[["4858a82a295aa484"]]},{"id":"ec246cd684064818","type":"inject","z":"84622180359efd62","name":"0,0","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Pruefdruck","payload":"0,0","payloadType":"str","x":350,"y":600,"wires":[["4858a82a295aa484"]]},{"id":"10a88fb2008e0ae3","type":"debug","z":"84622180359efd62","name":"Choice","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":730,"y":640,"wires":},{"id":"45894a54ee438d43","type":"comment","z":"84622180359efd62","name":"Create a Variable to serve the "Store" information to all nodes","info":"","x":490,"y":840,"wires":},{"id":"30687fc843b5dfb4","type":"comment","z":"84622180359efd62","name":"Input","info":"","x":510,"y":600,"wires":},{"id":"9502cb7ba3de449d","type":"comment","z":"84622180359efd62","name":"Function which should transfer informations if store== true ","info":"","x":1050,"y":640,"wires":},{"id":"3ecf675016fdfbf3","type":"comment","z":"84622180359efd62","name":"Problem: This Button needs a Trigger (new Information) but the Information is alread at the input","info":"","x":1160,"y":720,"wires":},{"id":"7763f99169395494","type":"ui_group","name":"Group 1","tab":"dde642b08fea7c32","order":1,"disp":true,"width":6},{"id":"dde642b08fea7c32","type":"ui_tab","name":"Test","icon":"dashboard","order":8,"disabled":false,"hidden":false}]

Please can you help.

Thanks in advance Clemens

You need to format the code correctly when posting.

If I am reading what you said correctly:

inputs are giving you information and you only want it stored if you press a button?

Question though:

How fast is the information arriving?

If it is arriving too quickly there will be problems.

Putting that aside:
A message arrives. It is stored and if you press the button it is saved.

You can do this a couple of ways.
But basically the idea is like this:

Message arrives.
Store the message in context.
If you press the button, that message is then passed to the output - to the next node.
Otherwise just store the next message when it arrives.

I use the Q-gate node (here) for this type of things... It stores messages based on various conditions and can be setup to release messages via a trigger message sent when a button is pressed.

1 Like

Dear all
thanks a lot for your feedback. I will look for the Q-Gate button, which seems to solve my problem.
... meanwhile
after a lot of testing I solved my problem by adding a trigger node infront of the store function. This trigger node fires every 0,5 s the information into the store function and wenn the "Go" Signal arives the Stor function sends out the stored message.

Problem solved
You can close this treat

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.