Turn on valve for x minutes, then off

Hello,

I need some help. I'm integrating greenhouse automatization, and I want to turn off/on solenoid valve via MQTT.
My idea is to have a pop up or something on some dashboard button to prompt how much time do I want it to be on, and after that time, it should send MQTT command to turn it off.

Any ideas?

Welcome to the forum @skrgahr.

You can use a Trigger node to send one message and then, after a delay, another. You can set the delay by setting msg.delay.

Thank you for your response.

I know about Trigger, that would be fine, but i need some prompt (dropbox with values like 5M,15M,1H,2H, etc..). I cant push that value to delay, or can I?
I just started with node-red few days ago, I already did most of my ideas and I love it.

You will have to convert 5M to the appropriate milliseconds value. Probably easiest in a function node.

Have you watched the node-red essentials videos linked from the node-red docs. It would be worth spending an hour watching them.

In fact each element in a dropdown has two entries, the text displayed and the value fed associated with that text (I can never remember which is which, I always have to look it up, or just try it). So you can configure the dropdown to show 5M, 15M etc with the values being the equivalent millisseconds which you can feed to the Trigger node.