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

Reduce update interval in Ondilo Ico #116989

Merged
merged 1 commit into from
May 7, 2024

Conversation

nijel
Copy link
Contributor

@nijel nijel commented May 7, 2024

Proposed change

The API seems to have sticter rate-limiting and frequent requests fail with HTPP 400.

Fixes #116593

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented May 7, 2024

Hey there @JeromeHXP, mind taking a look at this pull request as it has been labeled with an integration (ondilo_ico) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of ondilo_ico can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign ondilo_ico Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@JeromeHXP
Copy link
Contributor

@nijel I don't think this is the issue. Currently event the authentication page to get the token does not work (so you can't create a new instance) and Ondilo told me they are still working on their API issues. If the refresh frequency is an issue, we'll lower it, but let's first wait for them to solve their issues.

@nijel
Copy link
Contributor Author

nijel commented May 7, 2024

I might be wrong, but my tests look like there is an hourly limit for requests per IP address and once you reach that, any request will fail with HTTP 400.

Tested using this script:

client = Ondilo(token)
pools = client.get_pools()
print("Found all those pools: ", pools)
pool_id = pools[0]['id']
print(client.get_pool_config(pool_id))
print(client.get_last_pool_measures(pool_id))
print(client.get_ICO_details(pool_id))
print(client.get_pool_histo(pool_id, "temperature", "day"))

I can execute it four times until it gets HTTP 400, and it then gets it for the next hour.

It might be some temporary workaround on their side, so it might eventually disappear.

@joostlek joostlek marked this pull request as draft May 7, 2024 10:31
@JeromeHXP
Copy link
Contributor

Yes there are limit: 5 req/s, 30 req/h. That's per user. So indeed it could be an issue when someone has multiple ICOs, that's why at first the frequency was much higher but people complained. I'm writing Ondilo right now asking them if this can be the problem.
FYI, the component right now uses get_pools, get_ICO_details and get_last_pool_measures APIs every 5 minutes, which should be below their limit.

@nijel
Copy link
Contributor Author

nijel commented May 7, 2024

What I see, this happens per IP address. When Home Assistant could not fetch the data, I could do that from another server using the same token. Now I'm getting 400 on that server and Home Assistant works just fine with changes I've posted here. But still, this is just my observation.

@JeromeHXP
Copy link
Contributor

Feedback from Ondilo: all that mess in the last days was related to the quotas limits. I suppose it was not active previously and when they tried to active it, it created lots of issues, especially on the authentication part. They have supposedly solved all their issues now. The limit is indeed 30 req/h per user so we need to reduce the frequency. I think 20 minutes should be enough as we make approximately 3 req per check, plus the auth ones.

The API seems to have sticter rate-limiting and frequent requests fail
with HTTP 400.

Fixes home-assistant#116593
@nijel nijel marked this pull request as ready for review May 7, 2024 17:46
@joostlek joostlek changed the title Ondilo: reduce update interval Reduce update interval in Ondilo Ico May 7, 2024
@joostlek joostlek merged commit 789aadc into home-assistant:dev May 7, 2024
19 of 20 checks passed
@nijel nijel deleted the ondilo-interval branch May 7, 2024 17:55
@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2024
@joostlek joostlek added this to the 2024.5.4 milestone May 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing entities since 01.05.24 11 p.m. even before the update to 2024.5
4 participants