Add retry for rooftop sites collection #12 #26
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I think is going on with #12 is that 'random' 429 errors from Solcast (i.e. "Back off, we're busy!") prevent the integration from loading properly on startup. This causes sensors to go missing, which is sub-optimal.
Caching rooftop sites is one option, and I like it, but that carries real-world use case implications (add array? delete array? modify array? rename array?). There would have to be an easy and intuitive way to force refresh the cache, which is unlikely. Or a once-a-day attempt at refreshing the cache.
Another option is simply retrying until the data can be had.
This marge attempts a retry approach, where for up to one minute it will try every six seconds.
It's going to be very difficult to test this, because how can you guarantee Solcast will be busy on any given hour/minute/week/etc. and return a 429? And the only real way of testing is repeatedly restarting HA so that the integration loads the rooftop sites, which it only does on startup.