core: Steam online, API timeout and full shutdown after a period
The problem
The last couple months (estimated) the Steam Online API integration has been working less than optimal. When you configure a set of accounts to check status on (for myself I have 25 accounts selected from my friend list), it will work okayish for a day or two, and then it will show unavailable more and more often, and over time just completely time out with a permanent unavailable.
If you leave the integration disabled for more than 24 hours, you can restart it and the cycle starts over again. I read somewhere that Steam API has 100.000 requests for day as limit, so my question he is; can we set a timer on when we check status for Steam? It would be sufficient with 1 time per minute, for a 24 hour period it would mean 36.000 API calls per day (if it require one call per account).
Last year this integration was “slower” in the sense that it had a 30 seconds update frequency, but I do think it’s now quicker than 30 seconds, and maybe it should be reverted to keep the API session alive and not forcing it to timeout/close down.
What version of Home Assistant Core has the issue?
core-2023.6.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
Steam Online
Link to integration documentation on our website
https://www.home-assistant.io/integrations/steam_online
Diagnostics information
Example YAML snippet
No response
Anything in the logs that might be useful for us?
File "/usr/local/lib/python3.11/site-packages/steam/api.py", line 171, in download
raise HTTPError("Server connection failed: {0} ({1})".format(reason, code))
steam.api.HTTPError: Server connection failed: Too Many Requests (429)
Logger: homeassistant.config_entries
Source: config_entries.py:429
First occurred: 12:07:45 (1 occurrences)
Last logged: 12:07:45
Config entry '<account-name>' for steam_online integration not ready yet: Server took too long to respond; Retrying in background
Additional information
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 45 (8 by maintainers)
No errors in 24 hours using 22 entities.
🙄 I went ahead and fixed the issue directly in the source files using the API guidelines described below: https://steamcommunity.com/discussions/forum/1/3492005739881311668/ According to findings on the ArchiSteamFarm github, extension developers will need to forcibly cap the number of matches returned to 2000 (via the “count” parameter), and introduce other delays to guarantee only 1 request every 4 seconds.
A quick description of what I did:
coordinator.py\config\custom_components\steam_online…and, whala! It started working correctly right after HA reboot! It’s been working ever since.
For a quick fix, just follow these instructions:
steam_online(and its contents) from the downloaded zip file to:\config\custom_components\so it ultimately looks like: ``\config\custom_components\steam_online`You can see the changes I made if you look at the modified
coordinator.pywhen compared to the original onecoordinator (original).pywith a Diff tool.Hopefully, an official HA Core Integration developer can make these changes to the official repo. I can’t do it myself.
Enjoy!
PS: A special thanks to ArchiSteamFarm GitHub developers who originally identified what specifically was causing the issue and how to fix it.
WARNING: I need to do a little more testing. I think I actually need the original Steam integration GUI even for the custom integration that replaces it. More soon…
The user-based throttle function you are seeking has been discussed above. What still would be implemented is an exponential back-off when we hit 429 errors. A function like that should belong in the PyPI package IMO. That would not be available for manipulation by the user.
Edit: or some other calculation. This might be available in API returned data or it might not be. Some APIs actually tell us how many calls are still available.
I am having the same problems and I am only monitoring 1 account. I certainly don’t think that I am reaching steams api limit.
I do also get this error quite often when I try to configure, I need to then restart HA and then try again
If you’re talking about self-automating the process, I assume you mean disable the polling here?
And then use Reload for the whole service on your own given timer/automation?
Edit: Previously I used to do a reload_config_entry and it works when you do it on every single entity, but I assume there is a sensible way to reload the whole integration, that I am just not finding?