How to enable and disable the notification node using a button from the dashboard

Hello everyone. I am developing an application through node red whose main objective is to read the information of sensors through the mqtt protocol.

But anyway, I'll get straight to the point: I intend to implement a notification system in my app. In a way, if a given sensor's data exceeds the maximum allowed value, the notification is activated. So far so good. through a function node I was able to implement the logic through an if and a comparison. I only compare the msg.payload with a value and if the condition is met the msg.payload is returned until notification.

Here's my problem: I wanted to implement a button on the dashboard to activate notifications if necessary, a kind of "don't be disturbed".

In what ways could you do this?

I have already tried to insert in the if within a function node the value of the button and the maximum value of the sensor. if both conditions were true the notification shown on the screen. but it didn't work.

If anyone has another solution to my problem through dashboar, I would be grateful if I checked.

Thank you.

Have the button toggle flow or global context variable.

Then use a switch or function to check the flow/global value state. If its "off", stop the flow & so forth.

1 Like

You could take a look at node-red-contrib-simple-gate.

1 Like

I installed the gate node and connected the button to it, as well as the mqttin (input of sensor data). I programmed the button with the open and close states.

It is working as desired. information is only sent for notifications only when the button is activated (open).

It was the most simple and functional way I found.

Thanks a lot for the help.

2 Likes

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