From e37e4d771867e39e573fe4ca948c10c03baa53c5 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Tue, 18 Mar 2025 01:13:27 -0400 Subject: [PATCH] Clean-up severe thunderstorm and tornado alert presentation --- weather/alerts_filter.js | 23 +++++++++++++++-------- weather/defiance.js | 28 ++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/weather/alerts_filter.js b/weather/alerts_filter.js index 730aad2..5d4a816 100644 --- a/weather/alerts_filter.js +++ b/weather/alerts_filter.js @@ -34,13 +34,20 @@ let tornado = alerts.filter(function(alert) { // If there are any alerts, return them -msg.ts = ts -msg.ts_count = ts.length +let tstormMsg = { + "payload": { + "alerts": ts, + "count": ts.length, + "tornado_possible": tstp.length + } +} -msg.tstp = tstp -msg.tstp_count = tstp.length +let tornadoWarnMsg = { + "payload": { + "alerts": tornado, + "count": tornado.length + } +} -msg.tornado = tornado -msg.tornado_count = tornado.length - -return msg \ No newline at end of file +node.send([tstormMsg,tornadoWarnMsg]) +node.status({fill:'green',shape:'dot',text:'Alerts Updated'}) \ No newline at end of file diff --git a/weather/defiance.js b/weather/defiance.js index 0f9443f..54ab314 100644 --- a/weather/defiance.js +++ b/weather/defiance.js @@ -1,4 +1,5 @@ let alerts = msg.payload.features +let tornado_possible = false // Filter for Severe Thunderstorm Warnings @@ -23,6 +24,10 @@ let tstp = alerts.filter(function(alert) { } }) +if (tstp.length > 0) { + tornado_possible = true +} + // Filter for Tornado Warnings let tornado = alerts.filter(function(alert) { @@ -34,13 +39,20 @@ let tornado = alerts.filter(function(alert) { // If there are any alerts, return them -msg.ts = ts -msg.ts_count = ts.length +let tstormMsg = { + "payload": { + "alerts": ts, + "count": ts.length, + "tornado_possible": tornado_possible + } +} -msg.tstp = tstp -msg.tstp_count = tstp.length +let tornadoWarnMsg = { + "payload": { + "alerts": tornado, + "count": tornado.length + } +} -msg.tornado = tornado -msg.tornado_count = tornado.length - -return msg \ No newline at end of file +node.send([tstormMsg,tornadoWarnMsg]) +node.status({fill:'green',shape:'dot',text:'Alerts Updated'}) \ No newline at end of file