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.
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;
}