8000 Error 429 – Too Many Requests · Issue #165 · custom-components/zaptec · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Error 429 – Too Many Requests #165

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

Open
davee640 opened this issue Feb 18, 2025 · 9 comments
Open

Error 429 – Too Many Requests #165

davee640 opened this issue Feb 18, 2025 · 9 comments

Comments

@davee640
Copy link

Hello,
I am encountering an issue with the Zaptec integration for Home Assistant. An error message appears: "Error 429 – Too Many Requests." We have 16 charging stations in the installation, and synchronization is being refused. Do you have a solution?

Thank you

David

@sveinse
Copy link
Collaborator
sveinse commented Feb 19, 2025

There is a limit on how frequent requests can be sent to Zaptec cloud. For many chargers, the polling interval (default 60 seconds) must be reduces. See #158

@davee640
Copy link
Author
davee640 commented Apr 6, 2025

Hello,
Thank you for your response.
I have already tried several intervals, but the result is not good. It indicates that the entities are not available.
Here are several pictures

Image
Image
Image

.
Thank you in advance for your help.

@sveinse
Copy link
Collaborator
sveinse commented Apr 6, 2025

How long intervals did you test with? When you get 429 Too many requests its the Zaptec cloud that refuses to deliver data. The only real fix to this would be to reduce the request frequency, as we have no control over the limits which Zaptec enforce on their interfaces.

Are you able to dump the diagnostics? See the front page readme for a description how.

@Olen
Copy link
Contributor
Olen commented May 9, 2025

Since there is no option to configure the poll interval, this is just a quick guide to do it without modifying the code.

First, disable polling.

  • Go to Settings -> Devices -> Zaptec and click the three dots on the right, next to number of devices and entities.
  • Click system options
  • Disable polling

Image

Next, create a simple automation to poll based on a schedule.

  • Settings -> Automations -> Create Automation
  • As trigger, you can for instance set it to run every 2 minutes or whatever suits your needs, and that will not cause any more 429s. The period required depends on your number of devices. 2 minutes seems to work for my installation.

Image

  • As action, you select "Home Assistant Core Integration: Update Entity
    Image
  • As "Entity to update", just select any entity that the Zaptec integration provides (any sensor or binary sensor)

You do need to add all the entities. Just one single entity from any of the devices will suffice to poll all the devices at the set interval.

@thecoldwine
Copy link
thecoldwine commented May 14, 2025

Hello, Zaptec is here.

We do have a rate limit of 10 requests per second per user. There is a high chance the frequency of the requests is too high. We do recommend doing two things:

  1. Use exponential backoff retry.
  2. Use jitter on the requests.

https://pypi.org/project/retry/ Is a good library that has built in policies.

@sveinse
Copy link
Collaborator
sveinse commented May 14, 2025

Maintainer here.

Thank you @thecoldwine, I will take a look at this.

A wish from me were that more services and datapoints were updated via the push mechanism (ServiceBus). It would reduce the need for continuous and regular polling. That would in turn decrease the latencies for the user and lessen the request load on Zaptec cloud. My 2 cents.

@thecoldwine
Copy link

@sveinse we are looking into enabling a lightweight push mechanism for non-enterprise customers (we do have Service Bus for enterprise / b2b integrations).

I have no details to share on a specific technology or timelines, but it is definitely on our radar.

@sveinse
Copy link
Collaborator
sveinse commented May 14, 2025

Hello, Zaptec is here.

We do have a rate limit of 10 requests per second per user. There is a high chance the frequency of the requests is too high. We do recommend doing two things:

  1. Use exponential backoff retry.
  2. Use jitter on the requests.

https://pypi.org/project/retry/ Is a good library that has built in policies.

There is already exponential and jitter implemented in the code. But it only does this when a request fails. So with this in mind, is there anything that's missing?

# Implement exponential backoff with jitter and sleep before
# retying the request.
delay = delay * API_RETRY_FACTOR
delay = random.normalvariate(delay, delay * API_RETRY_JITTER)
delay = min(delay, self._max_time)
if DEBUG_API_CALLS:
_LOGGER.debug("Sleeping for %s seconds", delay)
await asyncio.sleep(delay)

@thecoldwine
Copy link

@sveinse if it retries on 429 it is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0