Background
Creating a piston to tap into NOAA (emergency alerts) via webCore. The plan is if the data is truly NOAA format, that I might be able to use it to trigger some automation at a remote location. The current piston state is simplified to ensure the data looks ok and given I ran into a few questions. I made a few assumptions and ran into some questions. I’d appreciate some re-education (very new to webCore).
Questions\Assumptions
- Is anything detectable to signal the end of an array when walking through each element? Null, 0, or the like? I just assumed using any value less than an epoch value of about an hour ago would be invalid alert data and was probably the end of the array.
- In my search, I saw some references to loop array problems (possibly due to bad weather underground data) that could really screw up webcore? Hoping the index limit of 20 and checking for semi-valid data may help.
- I’m a little concerned that I’m accessing the two related weather fields in two separate API Calls (i.e. not atomic). If an API call is made at line 32 to retrieve a epoch date and on line 33 an API call retrieves the alert message and the data changed between those two lines, it seems like I could run into a couple minor scenarios. Correct? Would the only way to address it be to add logic after line 33 to re-read the epoch and verify nothing changed and if so, re-do it?
- Is there a way to access the “alerts” in whole with all various member objects intact so that you could loop through the different fields without multiple API calls?
- I suppose there is no way to trigger an event from webCore’s weather? Would be nice to process only upon change and do so closer to real time given this is moments away severe weather yet I don’t want to be firing off a 30 second timer.
FYI, not planning to use this in place of battery powered emergency radio or similar and wouldn’t recommend it as a replacement given the scanning latency and possibility of internet or power outage or similar.