Improve Home Assistant compatibility: numeric-only output, 15-min caching, fewer logins#1
Open
Improve Home Assistant compatibility: numeric-only output, 15-min caching, fewer logins#1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
First off — a huge thank you to @joestanding for the original work on this project. 🙏
It’s been a real help, and this little fork is simply my attempt to make it a touch more “Home-Assistant-friendly” and a bit more forgiving when left running day in, day out.
What’s changed
Keeps hold of your session – Cookies and user info are saved locally so we don’t have to log in every time.
A bit less chatty – Adds a 15-minute cache, so we only ask the API when we really need to.
One door in and out – All requests now go through one _api() method, which:
Silently retries if the network has a little wobble.
Logs back in automatically if your session has wandered off.
No login frenzy – Won’t keep bashing the login endpoint if it’s already failed recently.
Grace under pressure – If the API does go quiet, we’ll politely hand back the last good number rather than sulking.
Why
The aim here is simply to:
Reduce the load on the API.
Keep the data flowing smoothly in Home Assistant.
Make the script “set-and-forget” reliable without nagging the server unnecessarily.
If you’re happy with it, I’ll keep this in sync with upstream in case anything changes on the Gym Group side.
Thanks again for the original code — it made this much easier. 🍵