Ui-switch node and e-mail

Hello, I'm using (v1.3.5) of system.
I have built a room temprature indicator.
I would to use e-mail notification according to the switch is on.
The e-mail sending is working correctly.
I just can't create the switch related sending method.
Please help to solve this problem.

Welcome to the forum @gytomig2.

One way to do it would be for the function node to set a context variable according to the output from the switch flow.set('sendemail', "YES") or flow.set('sendemail', "NO")

Then the switch node before email can test the value of flow.sendemail.

Thank you 'jbudd' your answer.
Sorry but it is not easy to me.
My target is the next:
If the room temperature less than 19 °C or higher than 21 °C I need an e-mail message.
But when I read the e-mail I would to stop the automatic e-mail sending with a switch (for example).
I'm a programmer (visual basic, Java, LabView, etc.), but unfortunately this NodeRed logic is new for me.
I have to catch this kind of logic method, but it comes slowly :slight_smile:

these helped me a lot. may be it will to you too, give it a try

Thank you 'smanjunath211' and 'jbudd' the ideas.
I used your recommendations and read some informations about the global variables.
And voila the problem solved.

var sendemail=global.get('sendemail') || "NO";
var switch1=context.get('switch1') || 0;
var topic=msg.topic;

if (topic=="s1")

if (switch1)
    global.set('sendemail', "YES");
if (!switch1)
    global.set('sendemail', "NO");

return msg;

Node_Red question v02b

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