PLEASE NOTE : after any update of the driver code, even if you use Hubitat Package Manager, you should open the virtual device, click 'Save Device', then click 'Save Preferences'.
There are issues with the weather.gov alert API. All seems to work as expected when there is an actual current alert. However, if there are no current alert, the API is not returning a valid response.
The expected response to a 'no current alerts' condition would be a valid response to the poll with a 'null' for the current alert ('event'). When that condition is detected the code responds with 'There are no current weather alerts'. However, because there is no valid response, the code responds to that condition with a response of 'Weather alerts are not available'.
This same code use to work, so something must have changed on the weather.gov API side. I have no workaround for now. Hopefully the weather.gov site will get corrected. If not, at least for now, valid alerts do appear to show correctly, but 'Weather alerts are not available' may mean either that the weather.gov site is down or busy so alerts are not available, or, that the site is available and there are no current alerts. I have no way to distinguish between the two conditions as it is now.
Restored 'certainty' to the weather.gov alert poll.
There is a known issue with the weather.gov API at this time. It does not return a vald response when there are no alerts, so the driver will return a 'Weather alerts are not available' when this condition exists. Their reponse was: "There is some maintenance that is going on this time. Your patience is appreciated. No estimated time of return of service is known."
PLEASE NOTE : after any update of the driver code, even if you use Hubitat Package Manager, you should open the virtual device, click 'Save Device', then click 'Save Preferences'.
Changes: Significant code refactoring by @nh.schottfam (Thanks!). Goals where to:
remove database accesses from the weather driver, as these do cause a lot of memory and JVM (Java Virtual Machine) resources consumption on HE.
Removed a lot of string creation done by the JVM. This is avoiding the creation of so many string constants for comparison.
Fixed some issues in variable mis-spellings
Cleanup of dead code based on analysis by IntelliJ.
Redisigned the threedayfcstTile, inspired by @pmasl77.
Other than the threedayfcstTile there are no changes to features or functions.
There is a known issue with the weather.gov API at this time. It does not return a vald response when there are no alerts, so the driver will return a 'Weather alerts are not available' when this condition exists. Their reponse was: " There is some maintenance that is going on this time. Your patience is appreciated. No estimated time of return of service is known. "
PLEASE NOTE : after any update of the driver code, even if you use Hubitat Package Manager, you should open the virtual device, click 'Save Device', then click 'Save Preferences'.
Changes:
Re-worked how the api.weather.gov poll works to remove dependency on it returning a valid response code. It will now report 'No current weather alerts' if there are no alerts returned in the poll, even without a valid response code of 200 (OK).
UPDATED again at 5:00 PM EDT for a minor parentheses correction (thanks @nh.schottfam). That should not cause any errors, but it may change the logic. I did NOT increment the version. If you pulled the code prior to 5:00 EDT on 9/14/2020 you should pull it again.
Changes:
Removing 'severity' and 'certainty' restrictions from alerts poll. This was excluding some 'minor' and 'unlikely' alerts. Now the only alerts that are excluded are 'past' alerts.
Now pulls weather alerts from OpenWeatherMap instead of weather.gov.
Various cleanups and bug fixes (from @nh.schottfam, Thanks!)
OpenWeatherMap now provides " Government weather alerts data from major national weather warning systems" This driver now uses that as the source for all weather alerts. This means that alerts are no longer exclusive the the United States. For the list of all sources that OWM claims is uses look here.
At this time only the first alert is shown, even if there are multiple alerts. I will look into displaying more than one alert if those exist in a future release.
Additional attributes available include:
alertDescr = The first 1,024 characters of the detailed alert description.
alertSender = The source of the alert.
Changes:
Updated URLs in the dashboard tile hyperlinks to take you to a OWM location specific page for details, including any weather alerts. (Thanks @arnb)
Thank you Matthew! That works perfectly on platforms and browsers supporting geolocation, including: Chrome on Windows, Firefox on Windows.
However, some platforms I'm using, Fully Kiosk Browser on Android and Amazon Fire OS (for my Dashboards), and Vivaldi on Windows, have geolocation issues and always show London, UK until the location is set manually, then the site stores the city code and units information in cookies and it works the next time entered.
To get the correct city it must be entered as cityname, 2digit country code
Here in the US, state code is not included with the results. This is problematic when the search returns numerous results.
Not much you can do about this, just letting people know.