How to use NodeRed to create email notifications

Hi all, I’m working on a project for our local community whereby when lightning is detected within X miles from my Tempest, that it will trigger an email message to warn folks to get out of the pool, or seek shelter indoors. I have nodered installed, and I can see observation json.


I am new to NodeRed, but I think it is capable of making this happen. I just need to find a way to trigger an action based on the right input.

I would be super grateful for any help.

In node-red add a palette via ’ manage palette’
install tab and type email in search modules

I loaded the first one

and you get a few new options to use

image

1 Like

Eric, thank you - this was very helpful. I also was able to consult ChatGPT to generate a function to normalize the alerts and set the subject:

var lastSentTime = context.get('lastSentTime') || 0;
var currentValue = msg.payload.uvIndex;

if (currentValue >= 8 && (Date.now() - lastSentTime) > (60 * 60 * 1000)) {
    // Send the message and update the last sent time
    context.set('lastSentTime', Date.now());
    msg.payload = "UV Index is now: " + currentValue + ".  Please take precautions to limit exposure.  We will check again in 1 hour.";
    msg.topic = "High UV Index Alert";
    return msg;
} else {
    return null;
}

and also for wind:

var lastSentTime = context.get('lastSentTime') || 0;
var currentValue = msg.payload.windSpeed;

if (currentValue >= 20 && (Date.now() - lastSentTime) > (60 * 600 * 1000)) {
    // Send the message and update the last sent time
    context.set('lastSentTime', Date.now());
    msg.payload = "Wind speed of " + currentValue + "MPH detected!  Please be sure to check and secure loose items in your yards.  We will check again in 10 hours.";
    msg.topic = "High Wind Alert";
    return msg;
} else {
    return null;
}
1 Like