-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Suggestion to work around failed updates #138
Conversation
The logs seem to be working fine
But I am getting this lot below too a lot in this version. Sometimes with the If I examine the DEBUG logs more closely I notice that after every full update HASS or this integration seems to want to load quite a few items with the
|
Seems to be fixed by the previous commit - apparently it must return data. New logs on a failed retrieval:
|
Hi @jcjveraa thank you for your contribution! I find it an interesting concept to cache the data in case responses are incorrect. I never considered this as I assumed the server wouldn't have any issues. One downside of serving cached data is that it can become stale (for example the weather this week has been changing a lot; sunny, rainy, hail, lightning). With the default interval of 5 minutes and allowing 6 failures we can end in a situation with showing stale data for 30 minutes. Since we don't know why there is a server-side issue, I think having no data isn't that bad, it shouldn't trigger anything on the user side (eg. when sunny for 20 minutes open awning). |
To keep track of api availability maybe you clould create a sensor "API beschikbaar" |
I wouldn't suggest doing that, that will make each sensor by itself useless, you would always need to check such a status to know if you can use the value. If you really want to do such a check you can check the timestamp of |
|
Not like this, but if you want to, you need to check that the timestamp is older than your configured scan interval |
Hi @golles, perhaps this could be an idea? Ideally the API is 'fixed' to return non-corrupt json, but there might be other reasons too why the API would not be available - i.e. we can't rely on the API always being there. To allow for that, we could implement something like this to ensure a single failed update does not turn the entities 'unavailable'.
I have this running with my own API key on a 'devcontainer-hass' now, I'll leave it running for a few hours to see if this has actually worked as expected. I have zero experience with HASS development, but my assumption is that the state of the integration's entities will only become 'unavailable' if an error is thrown.
Ideally for me (and perhaps other users):
Note: treat this as a 'stub', should be expanded with tests etc, but unfortunately I'm not too familiar with HASS python coding and my VSCode IDE PyLance doesn't seem to pick up the installed requirements_dev packages, so no guarantee I will do that for now
It seems to work so far.
As is, a 20 minute (2 failed updates) gap in the data:
With this PR (I started up HASS around 09:06):