Triggering when a threshold is met in NodeRED without re-triggering

I don’t know why I can’t figure this out.

If I want something to happen when the state of a sensor exceeds a specific value, but only happen one time, how would I do it?

Imagine the state of your 3D printer reaching 95% then having a notification sent, but only one time, not every time the state changes above 95%.

Use the ha trigger node on disabled mode. Say the 3D printer informs a job start then you can enable the trigger node on that event with msg.payload “enable” , then that node will be listening on the printer advance percentage, you can put a constrain over 95% , so once trigger node fires above % required will pass to the next node, send notification, and then go back with msg.payload “disable” to deactivate the trigger node on percentage event. I am not at my server now so I cannot export you a sample atm.

Derp. Trigger State node…duh. I forgot about that.

So I could enable, fire the flow, change the message, route it back to the input of the trigger, then after the notification, put a wait until the printer hits 100%, then send enable back to the trigger. Got it.

Hi guys! May I ask for an example? I also have the same problem needing a trigger once node but as I am a newbie, I cannot figure out the pseudocode written by subzero79. How you set it up on your system is ok with me.

But if you’re curious about my project, I have a state node that is outputting frequently. I would like for it to output only once. This is what I have now. It’s a water level sensor (ultrasonic sensor) that is detecting Empty Tank (< 0.40 m) and Full Tank (> 0.8 m). Once the tank is detected as empty, it should only send once. And once the tank is full, again once. As it is set now, like I said, it outputs frequently as long as conditions are met. And I don’t want to be dependent on the Pump Switch turning off.

Thank you so much!