const severeWarningEvents = ["Severe Thunderstorm Warning","Destructive Severe Thunderstorm Warning","Considerable Destructive Severe Thunderstorm Warning"] const tornadoWarningEvents = ["Tornado Warning","Radar Indicated Tornado Warning","Confirmed Tornado Warning","Tornado Emergency"] let alerts = msg.payload.features let tornado_possible = false let considerable_destructive = false let confirmed = false // Filter for Severe Thunderstorm Warnings let ts = alerts.filter(function(alert) { if (alert.properties && severeWarningEvents.includes(alert.properties.event)) { return true } }) // Filter for Severe Thunderstorm Warnings with tornado detection // that have a tornado possible parameter let tstp = alerts.filter(function(alert) { if (alert.properties && severeWarningEvents.includes(alert.properties.event) && alert.properties.parameters && alert.properties.parameters.tornadoDetection && alert.properties.parameters.tornadoDetection.length > 0) { let tornadoPossible = alert.properties.parameters.tornadoDetection[0] return tornadoPossible === "POSSIBLE" } }) if (tstp.length > 0) { tornado_possible = true } // Filter for considerable destructive severe thunderstorm warnings let cdst = alerts.filter(function(alert) { if (alert.properties && alert.properties.event === "Considerable Destructive Severe Thunderstorm Warning") { return true } }) if (cdst.length > 0) { considerable_destructive = true } // Filter for Tornado Warnings let tornado = alerts.filter(function(alert) { if (alert.properties && tornadoWarningEvents.includes(alert.properties.event)) { return true } }) let confirmed_tornado = alerts.filter(function(alert) { if (alert.properties && alert.properties.event === "Confirmed Tornado Warning") { return true } }) if (confirmed_tornado.length > 0) { confirmed = true } // If there are any alerts, return them let tstormMsg = { "payload": { "alerts": ts, "count": ts.length, "tornado_possible": tornado_possible, "considerable_destructive": considerable_destructive } } let tornadoWarnMsg = { "payload": { "alerts": tornado, "count": tornado.length, "confirmed": confirmed } } node.send([tstormMsg,tornadoWarnMsg]) node.status({fill:'green',shape:'dot',text:'Alerts Updated'})