# Sanity check for NWS weather alert Flow

**URL:** <https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849>\
**Category:** General\
**Created:** [5 June 2020 19:10 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849 "2020-06-05T19:10:11Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodylinksystems](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bodylinksystems/32/23396_2.png) [@bodylinksystems](https://discourse.nodered.org/u/bodylinksystems)\
**Post date:** [5 June 2020 19:10 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/1 "2020-06-05T19:10:11Z")

</div>

I had this working but recent weather events weren't popping up as alerts on my dash. When I went to investigate, I am sure I broke something, then fixed it, and broke it again. I could use a sanity check.

The flow is very simple: Go to NWS [alerts.weather.gov](http://alerts.weather.gov) page for a county, check to see if there is a standard "no alerts right now" message (which only appears when there are no alerts, obviously), does a check to see if a TRUE or FALSE is passed -- TRUE means no alert and nothing pops up, FALSE means there is an alert, and the payload should be displayed as an alert.

This has been devlishly difficult to test as I can only really test it when there are real alerts. Any help or advice would be appreciated, I tried to make the alert flow as simple as possible but still managed to bang it up somehow.

```auto
[{"id":"1279864a.6f913a","type":"tab","label":"Weather Alert Flow","disabled":false,"info":"This flow looks for current weather alerts. By default it looks for tornado or thunderstorm, but it can be changed to look for hurricane, flood, or other alert."},{"id":"d4bb8926.65fd68","type":"inject","z":"1279864a.6f913a","name":"","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":true,"onceDelay":0.1,"x":150,"y":40,"wires":[["f6fe9d7c.fb7ad"]]},{"id":"cca7689b.bafc68","type":"http request","z":"1279864a.6f913a","name":"NWS Alert Feed","method":"GET","ret":"txt","paytoqs":false,"url":"https://alerts.weather.gov/cap/wwaatmget.php?x=HIC003&y=1","tls":"","persist":false,"proxy":"","authType":"","x":260,"y":140,"wires":[["4d989955.e8e8d8"]]},{"id":"f6fe9d7c.fb7ad","type":"function","z":"1279864a.6f913a","name":"Set User Agent String","func":"\nmsg.headers = {};\nmsg.headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36';\nreturn msg;","outputs":1,"noerr":0,"x":180,"y":100,"wires":[["cca7689b.bafc68"]]},{"id":"d1464890.346298","type":"comment","z":"1279864a.6f913a","name":"Set feed to be your county alerts feed.","info":"Use the NWS alert rss feed for your state from this list.\n\nhttps://alerts.weather.gov/","x":170,"y":180,"wires":[]},{"id":"f20b3f92.7a35a","type":"ui_toast","z":"1279864a.6f913a","position":"dialog","displayTime":"5","highlight":"red","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":true,"topic":"ALERT","name":"nws alert","x":680,"y":140,"wires":[[]]},{"id":"5358ae02.bb6a1","type":"switch","z":"1279864a.6f913a","name":"alert choice","property":"payload[1]","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":200,"wires":[[],["f20b3f92.7a35a"]]},{"id":"bb5848c4.39b7d8","type":"debug","z":"1279864a.6f913a","name":"check","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload[1]","targetType":"msg","x":590,"y":80,"wires":[]},{"id":"8d613c6f.a190e","type":"comment","z":"1279864a.6f913a","name":"Alert Feed Address","info":"The check explicitly looks for \"There are no active watches, warnings or advisories\" in the second TITLE tag of the xml return and does a check on it. If FALSE, nothing pops up -- if TRUE, you get the verbose weather alert.\n\n\nCounty Alert Feed\nhttps://alerts.weather.gov/cap/wwaatmget.php?x=HIC003&y=1","x":430,"y":240,"wires":[]},{"id":"22347a4e.96aa16","type":"comment","z":"1279864a.6f913a","name":"Alert text still needs formatting","info":"","x":1030,"y":280,"wires":[]},{"id":"19a61356.77355d","type":"string","z":"1279864a.6f913a","name":"active?","methods":[{"name":"contains","params":[{"type":"str","value":"\"There are no active watches, warnings or advisories\""}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":500,"y":140,"wires":[["5358ae02.bb6a1"]]},{"id":"4d989955.e8e8d8","type":"html","z":"1279864a.6f913a","name":"","property":"payload","outproperty":"payload","tag":"title","ret":"text","as":"single","x":410,"y":200,"wires":[["19a61356.77355d","bb5848c4.39b7d8"]]},{"id":"b2461177.e877d","type":"play audio","z":"1279864a.6f913a","name":"","voice":"43","x":750,"y":20,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [5 June 2020 20:24 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/2 "2020-06-05T20:24:22Z")

</div>

You appear to have posted only the request node, not the rest of the flow. Also please read this for how to share your flow here so that it is importable.

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

---

<div class="post-metadata">

**Author:** ![bodylinksystems](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bodylinksystems/32/23396_2.png) [@bodylinksystems](https://discourse.nodered.org/u/bodylinksystems)\
**Post date:** [5 June 2020 22:25 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/3 "2020-06-05T22:25:41Z")

</div>

Thank you. I went to that link and followed the info. Instructions don't work for chromebook for some reason, so I did it manually. Great start.

The HTML node outputs the right alert when it is available, but I can't get it to pass anything other than FLASE to the alert, when it used to pass the entire alert. It's something simple, but not for me right now. Perhaps I am handling the array wrong, but I usually had success spitting out message[1] since that's where the actual alert is.

```auto
[{"id":"1279864a.6f913a","type":"tab","label":"Weather Alert Flow","disabled":false,"info":"This flow looks for current weather alerts. By default it looks for tornado or thunderstorm, but it can be changed to look for hurricane, flood, or other alert."},{"id":"d4bb8926.65fd68","type":"inject","z":"1279864a.6f913a","name":"","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":true,"onceDelay":0.1,"x":150,"y":40,"wires":[["f6fe9d7c.fb7ad"]]},{"id":"cca7689b.bafc68","type":"http request","z":"1279864a.6f913a","name":"NWS Alert Feed","method":"GET","ret":"txt","paytoqs":false,"url":"https://alerts.weather.gov/cap/wwaatmget.php?x=HIC003&y=1","tls":"","persist":false,"proxy":"","authType":"","x":260,"y":140,"wires":[["4d989955.e8e8d8"]]},{"id":"f6fe9d7c.fb7ad","type":"function","z":"1279864a.6f913a","name":"Set User Agent String","func":"\nmsg.headers = {};\nmsg.headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36';\nreturn msg;","outputs":1,"noerr":0,"x":180,"y":100,"wires":[["cca7689b.bafc68"]]},{"id":"d1464890.346298","type":"comment","z":"1279864a.6f913a","name":"Set feed to be your county alerts feed.","info":"Use the NWS alert rss feed for your state from this list.\n\nhttps://alerts.weather.gov/","x":170,"y":180,"wires":[]},{"id":"f20b3f92.7a35a","type":"ui_toast","z":"1279864a.6f913a","position":"dialog","displayTime":"5","highlight":"red","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":true,"topic":"ALERT","name":"nws alert","x":680,"y":140,"wires":[[]]},{"id":"5358ae02.bb6a1","type":"switch","z":"1279864a.6f913a","name":"alert choice","property":"payload[1]","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":200,"wires":[[],["f20b3f92.7a35a"]]},{"id":"bb5848c4.39b7d8","type":"debug","z":"1279864a.6f913a","name":"check","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload[1]","targetType":"msg","x":590,"y":80,"wires":[]},{"id":"8d613c6f.a190e","type":"comment","z":"1279864a.6f913a","name":"Alert Feed Address","info":"The check explicitly looks for \"There are no active watches, warnings or advisories\" in the second TITLE tag of the xml return and does a check on it. If FALSE, nothing pops up -- if TRUE, you get the verbose weather alert.\n\n\nCounty Alert Feed\nhttps://alerts.weather.gov/cap/wwaatmget.php?x=HIC003&y=1","x":430,"y":240,"wires":[]},{"id":"22347a4e.96aa16","type":"comment","z":"1279864a.6f913a","name":"Alert text still needs formatting","info":"","x":1030,"y":280,"wires":[]},{"id":"19a61356.77355d","type":"string","z":"1279864a.6f913a","name":"active?","methods":[{"name":"contains","params":[{"type":"str","value":"\"There are no active watches, warnings or advisories\""}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":500,"y":140,"wires":[["5358ae02.bb6a1"]]},{"id":"4d989955.e8e8d8","type":"html","z":"1279864a.6f913a","name":"","property":"payload","outproperty":"payload","tag":"title","ret":"text","as":"single","x":410,"y":200,"wires":[["19a61356.77355d","bb5848c4.39b7d8"]]},{"id":"b2461177.e877d","type":"play audio","z":"1279864a.6f913a","name":"","voice":"43","x":750,"y":20,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 June 2020 08:03 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/4 "2020-06-06T08:03:27Z")

</div>

What type is the string node? node-red-contrib-something probably.  
I notice that the information you are want is in msg.payload[1], have you allowed for that in the string node, also the Switch node after the string node is testing msg.payload[1], is that correct?

> [@bodylinksystems](#):
>
> I went to that link and followed the info. Instructions don't work for chromebook for some reason

Interestingly that is the second report of problems with Chrome and those instructions. You should find that if you click the button first, then paste the text in then is should work ok.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 June 2020 08:25 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/5 "2020-06-06T08:25:33Z")

</div>

> [@Colin](#):
>
> What type is the string node? node-red-contrib-something probably.

@colin, the [flow inspector](https://flows.nodered.org/inspect) shows it to be [node-red-contrib-string](https://flows.nodered.org/node/node-red-contrib-string)

---

<div class="post-metadata">

**Author:** ![bodylinksystems](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bodylinksystems/32/23396_2.png) [@bodylinksystems](https://discourse.nodered.org/u/bodylinksystems)\
**Post date:** [6 June 2020 13:55 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/6 "2020-06-06T13:55:48Z")

</div>

> [@Colin](#):
>
> I notice that the information you are want is in msg.payload[1], have you allowed for that in the string node, also the Switch node after the string node is testing msg.payload[1], is that correct?

Thanks for the reply. So I found that if I checked the entire msg.payload up front, it used to solve the problem of an alert popping up no matter what. Then after passing that check, I want the msg.payload[1] to be actually in the alert. It's how I thought I handled the false positive by inverting the logic. If that makes sense, since it only is FALSE if there is an alert.

I'm at a loss as to why nothing is popping up when there is an alert now. Nothing seems to have changed on the NSW front.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 June 2020 14:01 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/7 "2020-06-06T14:01:22Z")

</div>

When debugging the first thing to do is to find out which node is not doing what you expect, so add a debug node showing what is coming out of the string node.

You can test it without waiting for an alert by using an Inject and a Change node to build a test message to pass in to the html node (or the string node).

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 June 2020 14:05 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/8 "2020-06-06T14:05:46Z")

</div>

In fact, having installed node-red-contrib-string I can see that you are testing msg.payload, but in fact the string you want to test is in msg.payload[1]. So that is not going to work.

Also note that you can use the builtin Switch node to do the test, you don't need to use a contrib node.

---

<div class="post-metadata">

**Author:** ![bodylinksystems](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bodylinksystems/32/23396_2.png) [@bodylinksystems](https://discourse.nodered.org/u/bodylinksystems)\
**Post date:** [6 June 2020 14:45 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/9 "2020-06-06T14:45:28Z")

</div>

> [@Colin](#):
>
> When debugging the first thing to do is to find out which node is not doing what you expect, so add a debug node showing what is coming out of the string node.

As it is now, I get an udefined return from the text node whih looks for "There are no active watches, warnings or advisories"

> [@Colin](#):
>
> Also note that you can use the builtin Switch node to do the test, you don't need to use a contrib node.

I am using both, because I need to check for the presence of the "no alert" text and then use the switch node to pass along a real alert if it is there. Are you saying I can remove the text node and just use the switch mode? I think the main confusion is that there isn't even a payload[1] unless there is an alert.

However, setting everything up to just look for payload[1] doesn't work. I recall going in and switching them all to [1] and I was left with no output.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 June 2020 14:53 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/10 "2020-06-06T14:53:52Z")

</div>

> [@bodylinksystems](#):
>
> As it is now, I get an udefined return from the text node

That is because it is expecting msg.payload to be a string, but it is an array. The easiest fix is probably to put a change node before the string node, to move msg.payload[1] into msg.payload.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 June 2020 15:00 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/11 "2020-06-06T15:00:56Z")

</div>

> [@bodylinksystems](#):
>
> Are you saying I can remove the text node and just use the switch mode? I think the main confusion is that there isn't even a payload[1] unless there is an alert.

Yes, The switch node can look for a string in msg.payload[1].  
Also, when I run your flow I see, in msg.payload[1] "There are no active watches, warnings or advisories"

---

<div class="post-metadata">

**Author:** ![bodylinksystems](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bodylinksystems/32/23396_2.png) [@bodylinksystems](https://discourse.nodered.org/u/bodylinksystems)\
**Post date:** [7 June 2020 02:00 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/12 "2020-06-07T02:00:44Z")

</div>

I get that from time to time too when I am fiddling with the flow. Still not working properly for me, I must be taking the wrong approach.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 June 2020 07:47 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/13 "2020-06-07T07:47:25Z")

</div>

Post what you have now and I will take a look. You weren't far off before.

---

<div class="post-metadata">

**Author:** ![bodylinksystems](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bodylinksystems/32/23396_2.png) [@bodylinksystems](https://discourse.nodered.org/u/bodylinksystems)\
**Post date:** [7 June 2020 12:42 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/14 "2020-06-07T12:42:09Z")

</div>

I appreciate it. Quite frustrated at this point. I used the new method of hitting the formatting button first, then pasting this time.

```auto
[
    {
        "id": "1279864a.6f913a",
        "type": "tab",
        "label": "Weather Alert Flow",
        "disabled": false,
        "info": "This flow looks for current weather alerts."
    },
    {
        "id": "d4bb8926.65fd68",
        "type": "inject",
        "z": "1279864a.6f913a",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "3600",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 150,
        "y": 40,
        "wires": [
            [
                "f6fe9d7c.fb7ad"
            ]
        ]
    },
    {
        "id": "cca7689b.bafc68",
        "type": "http request",
        "z": "1279864a.6f913a",
        "name": "NWS Alert Feed",
        "method": "GET",
        "ret": "txt",
        "paytoqs": false,
        "url": "https://alerts.weather.gov/cap/wwaatmget.php?x=HIC003&y=1",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 260,
        "y": 160,
        "wires": [
            [
                "4d989955.e8e8d8"
            ]
        ]
    },
    {
        "id": "f6fe9d7c.fb7ad",
        "type": "function",
        "z": "1279864a.6f913a",
        "name": "Set User Agent String",
        "func": "\nmsg.headers = {};\nmsg.headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36';\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 180,
        "y": 100,
        "wires": [
            [
                "cca7689b.bafc68"
            ]
        ]
    },
    {
        "id": "d1464890.346298",
        "type": "comment",
        "z": "1279864a.6f913a",
        "name": "Set feed to be your county alerts feed.",
        "info": "Use the NWS alert rss feed for your state from this list.\n\nhttps://alerts.weather.gov/",
        "x": 190,
        "y": 200,
        "wires": []
    },
    {
        "id": "f20b3f92.7a35a",
        "type": "ui_toast",
        "z": "1279864a.6f913a",
        "position": "dialog",
        "displayTime": "5",
        "highlight": "red",
        "sendall": true,
        "outputs": 1,
        "ok": "OK",
        "cancel": "",
        "raw": false,
        "topic": "ALERT",
        "name": "nws alert",
        "x": 640,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "5358ae02.bb6a1",
        "type": "switch",
        "z": "1279864a.6f913a",
        "name": "alert choice",
        "property": "payload[1]",
        "propertyType": "msg",
        "rules": [
            {
                "t": "false"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 530,
        "y": 100,
        "wires": [
            [],
            [
                "f20b3f92.7a35a"
            ]
        ]
    },
    {
        "id": "bb5848c4.39b7d8",
        "type": "debug",
        "z": "1279864a.6f913a",
        "name": "check",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload[1]",
        "targetType": "msg",
        "x": 650,
        "y": 40,
        "wires": []
    },
    {
        "id": "8d613c6f.a190e",
        "type": "comment",
        "z": "1279864a.6f913a",
        "name": "Alert Feed Address",
        "info": "The check explicitly looks for \"There are no active watches, warnings or advisories\" in the second TITLE tag of the xml return and does a check on it. If FALSE, nothing pops up -- if TRUE, you get the verbose weather alert.\n\n\nCounty Alert Feed\nhttps://alerts.weather.gov/cap/wwaatmget.php?x=PAC029&y=1",
        "x": 430,
        "y": 240,
        "wires": []
    },
    {
        "id": "22347a4e.96aa16",
        "type": "comment",
        "z": "1279864a.6f913a",
        "name": "Alert text still needs formatting",
        "info": "",
        "x": 1030,
        "y": 280,
        "wires": []
    },
    {
        "id": "4d989955.e8e8d8",
        "type": "html",
        "z": "1279864a.6f913a",
        "name": "",
        "property": "payload",
        "outproperty": "payload",
        "tag": "title",
        "ret": "text",
        "as": "multi",
        "x": 410,
        "y": 200,
        "wires": [
            [
                "884c75fb.36f078",
                "bb5848c4.39b7d8"
            ]
        ]
    },
    {
        "id": "884c75fb.36f078",
        "type": "change",
        "z": "1279864a.6f913a",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "payload[1]",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "There are no active watches, warnings or advisories",
                "fromt": "str",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 420,
        "y": 40,
        "wires": [
            [
                "5358ae02.bb6a1"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 June 2020 13:06 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/15 "2020-06-07T13:06:11Z")

</div>

A minor point, when exporting the flow it is better to select Compact at the bottom of the window, so it appears on one line.

You had changed the html select node to output multiple messages instead of an array, the rest of the flow assumes it is an array.  
In the final switch node you were testing msg.payload[1] but in the change node you set msg.payload true or false.  
You had the debug node set to show msg.payload[1] which generally isn't a good idea when debugging as you want to see what is in the payload, not make assumptions about whether the payload is an array or not. That was probably confusing you.  
The technique I used to debug is to start at the beginning with a debug node on the output of a node. Check that node is sending what you expect, then move on to the next node and check that, and so on.

Try this

```auto
[{"id":"ea59bf41.170328","type":"inject","z":"18c3846b.fec5fc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":40,"wires":[["27559896.19c0c"]]},{"id":"b49256dc.82eea","type":"http request","z":"18c3846b.fec5fc","name":"NWS Alert Feed","method":"GET","ret":"txt","paytoqs":false,"url":"https://alerts.weather.gov/cap/wwaatmget.php?x=HIC003&y=1","tls":"","persist":false,"proxy":"","authType":"","x":260,"y":160,"wires":[["3935b972.f4bed6"]]},{"id":"27559896.19c0c","type":"function","z":"18c3846b.fec5fc","name":"Set User Agent String","func":"\nmsg.headers = {};\nmsg.headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36';\nreturn msg;","outputs":1,"noerr":0,"x":180,"y":100,"wires":[["b49256dc.82eea"]]},{"id":"d4e7ef7c.1776f","type":"comment","z":"18c3846b.fec5fc","name":"Set feed to be your county alerts feed.","info":"Use the NWS alert rss feed for your state from this list.\n\nhttps://alerts.weather.gov/","x":190,"y":200,"wires":[]},{"id":"174bc408.d94a74","type":"ui_toast","z":"18c3846b.fec5fc","position":"dialog","displayTime":"5","highlight":"red","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":false,"topic":"ALERT","name":"nws alert","x":640,"y":160,"wires":[[]]},{"id":"482c4ac.2c441b4","type":"switch","z":"18c3846b.fec5fc","name":"alert choice","property":"payload","propertyType":"msg","rules":[{"t":"false"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":100,"wires":[["dfbc9986.7a50a"],["174bc408.d94a74"]]},{"id":"dfbc9986.7a50a","type":"debug","z":"18c3846b.fec5fc","name":"check","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":650,"y":40,"wires":[]},{"id":"422f2eb9.6cd15","type":"comment","z":"18c3846b.fec5fc","name":"Alert Feed Address","info":"The check explicitly looks for \"There are no active watches, warnings or advisories\" in the second TITLE tag of the xml return and does a check on it. If FALSE, nothing pops up -- if TRUE, you get the verbose weather alert.\n\n\nCounty Alert Feed\nhttps://alerts.weather.gov/cap/wwaatmget.php?x=PAC029&y=1","x":430,"y":240,"wires":[]},{"id":"3935b972.f4bed6","type":"html","z":"18c3846b.fec5fc","name":"","property":"payload","outproperty":"payload","tag":"title","ret":"text","as":"single","x":410,"y":200,"wires":[["c40471aa.4c3b2"]]},{"id":"c40471aa.4c3b2","type":"change","z":"18c3846b.fec5fc","name":"","rules":[{"t":"move","p":"payload[1]","pt":"msg","to":"payload","tot":"msg"},{"t":"change","p":"payload","pt":"msg","from":"There are no active watches, warnings or advisories","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":40,"wires":[["482c4ac.2c441b4"]]}]

```

---

<div class="post-metadata">

**Author:** ![bodylinksystems](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bodylinksystems/32/23396_2.png) [@bodylinksystems](https://discourse.nodered.org/u/bodylinksystems)\
**Post date:** [7 June 2020 13:36 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/16 "2020-06-07T13:36:08Z")

</div>

Thanks for the help. I usually move that debug node around to see what's what.

Right now as it is, I get the FALSE output -- which would seem right, however the alert pops up with a random H or U now, which makes no sense to me.

If I had the ability right now, I would build a little node that would take your county's NWS feed address as input an pop up an alert if there was one. With so many weather dashboards being built, I was surprised not to find one myself. And so here I am...

edit: It seems that I was still checking my pasted version of the alert, and not the one you offered. So no random characters this go around. I am getting proper output from the boolean with no alerts, but still have to find a way to inject a simulated alert payload. Ongoing...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 June 2020 14:13 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/17 "2020-06-07T14:13:29Z")

</div>

It depends how far back you want to do the inject. It would be easy enough to inject it after the html select node.

If there is an alert isn't it going to send multiple events? You can put an RBE node in the path to stop that if you need to.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 August 2020 14:13 UTC](https://discourse.nodered.org/t/sanity-check-for-nws-weather-alert-flow/27849/18 "2020-08-06T14:13:30Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
