johnwalicki / Node-RED-Severe-Weather-Alert-Map

Severe Weather Alert Map Node-RED Dashboard using The Weather Company APIs
Apache License 2.0
5 stars 3 forks source link

Next Loop #1

Open markusvankempen opened 4 years ago

markusvankempen commented 4 years ago

Hi John... when you import the flow some of the array are not initialize adding an entry || [] default arry will help with the error message - when starting this ... See Next Loop function var Severe = flow.get("SevereAlerts")||[];

markusvankempen commented 4 years ago

I add somefilter function and limitted the a amount of API calls eg if we have all the data form the US lets just filter the array by State and Severity Level ... vs calling the API again ... anyway just couple little things mvk.-node-red.flow.txt

johnwalicki commented 4 years ago

Thanks for the flow updates. Cool addition of Severity Levels. I like it. Adds a bit more complexity to an already advanced flow! I'm worried my flow already can overwhelm a novice Node-RED developer. This pushes it over the top. Ha.

I like the idea of reducing the extra calls to the TWC APIs if the flow already has all US alerts loaded. I just spent some time thinking about having the flow filter by AdminDistrictCode. In theory, the flow could make one call to get All US alerts, store that array in memory and then just filter on whichever State the user selects. The flow would never need to call the TWC more than the first time. It would simplify the flow substantially. At the expense of some extra runtime memory, that would be more efficient. I could delete the State "next loop".

BUT what's the point of this flow? I want to show how to make calls to the TWC APIs. If I delete the AdminDistrictCode logic, I lose that teaching example.

Here's what I'll do, I'll hatchet out the State code. Add the in-memory filter on the State / AdminDistrictCode selected in the drop down. That will simplify. Then, I can add your Severity dashboard nodes. I'll post the flow to github under a different name to preserve both.

In my original flow, there will never be a case where the flow variable SevereAlerts is null. It is set right before the http request nodes.

markusvankempen commented 4 years ago

Ok ... I see ... flow did work for me right away - I think in the end it was the "Init TWC API Key" inject which does not fire to set the API key when you update the "change" node for some reason it kept using the old (wrong API key) ... once i fired it manually and the apikey was set with work perfectly).... anyway no worries .... Cheers