Add watches for Defiance
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
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"]
|
||||
const tornadoWatchEvents = ["Tornado Watch"]
|
||||
const severeThunderstormWatchEvents = ["Severe Thunderstorm Watch"]
|
||||
|
||||
let alerts = msg.payload.features
|
||||
let tornado_possible = false
|
||||
@ -66,6 +68,24 @@ if (confirmed_tornado.length > 0) {
|
||||
confirmed = true
|
||||
}
|
||||
|
||||
// Filter for Tornado Watches
|
||||
|
||||
let tornado_watch = alerts.filter(function(alert) {
|
||||
if (alert.properties &&
|
||||
tornadoWatchEvents.includes(alert.properties.event)) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
// Filter for Severe Thunderstorm Watches
|
||||
|
||||
let severe_thunderstorm_watch = alerts.filter(function(alert) {
|
||||
if (alert.properties &&
|
||||
severeThunderstormWatchEvents.includes(alert.properties.event)) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
|
||||
// If there are any alerts, return them
|
||||
|
||||
let tstormMsg = {
|
||||
@ -85,5 +105,19 @@ let tornadoWarnMsg = {
|
||||
}
|
||||
}
|
||||
|
||||
node.send([tstormMsg,tornadoWarnMsg])
|
||||
let tornadoWatchMsg = {
|
||||
"payload": {
|
||||
"alerts": tornado_watch,
|
||||
"count": tornado_watch.length
|
||||
}
|
||||
}
|
||||
|
||||
let severeThunderstormWatchMsg = {
|
||||
"payload": {
|
||||
"alerts": severe_thunderstorm_watch,
|
||||
"count": severe_thunderstorm_watch.length
|
||||
}
|
||||
}
|
||||
|
||||
node.send([tstormMsg,tornadoWarnMsg,tornadoWatchMsg,severeThunderstormWatchMsg])
|
||||
node.status({fill:'green',shape:'dot',text:'Alerts Updated'})
|
Reference in New Issue
Block a user