Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Errors Cause Integration State To Bounce Frequently #70

Open
EdLeckert opened this issue Nov 2, 2023 · 3 comments
Open

API Errors Cause Integration State To Bounce Frequently #70

EdLeckert opened this issue Nov 2, 2023 · 3 comments

Comments

@EdLeckert
Copy link

Errors returned from the NWS API cause the integration state to become "unavailable" until the next successful data fetch. At a poll frequency of one minute, this intermittent behavior can happen frequently.

State Unavailable

The logged error is:

NWS Error

The data returned from the NWS API is something like:

An error occurred while processing your request.
Reference #102.ef3b2f17.1698861160.43265ae2

If this happens when no alerts are active it is hardly noticed. However, if an alert is active, any templates looking for a state (count) of ">0" will no longer evaluate to True. In my case, this sets my alert entity back to idle, causing automations to declare the alert "expired", only to declare a "new" alert a minute later when the API again responds with good data. When notifications are issued each time this happens, especially in the middle of the night, it can be extremely annoying.

I will propose a potential solution for this by way of a PR. If anyone has a workaround for this problem I would love to hear it.

@EdLeckert
Copy link
Author

With the proposed change in place, the sensor.nws_alerts entity remained stable throughout the alert period in spite of the fact that the API briefly returned errors numerous times beginning at about midnight. The repeated alert notifications from this bouncing of the service in the middle of the night would have been very annoying.

The change I am proposing is to essentially cancel the entity's update in the case of this specific error, as if the fetch attempt had never happened.

The entity's history:

NWS Alerts History

The error log:

Home Assistant Core
2023-11-04 00:05:26.281 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 00:16:29.049 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 00:17:29.054 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 01:06:33.213 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 01:21:33.059 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 01:23:33.357 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 01:27:35.260 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 02:06:38.214 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 02:09:39.246 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 05:04:14.284 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 05:08:15.221 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS
2023-11-04 08:02:49.109 WARNING (MainThread) [custom_components.nws_alerts] Error fetching most recent data from NWS

@EdLeckert
Copy link
Author

It appears that there was a PR to address this several years ago as #7, but those changes have been lost along the way.

@jhemak
Copy link

jhemak commented Sep 26, 2024

I came across this error today ... was the fix ever merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants