home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.59k stars 29.5k forks source link

Starling Bank now rate limit - integration throws errors #73225

Closed von-Chaps closed 2 years ago

von-Chaps commented 2 years ago

The problem

First, many thanks for this API, I find it very useful.

Very recently, Starling Bank introduced daily limits to the number of times the v2 accounts api may be called. The integration now throws; 429 Too Many Requests

I have included an extract from an email I received from Starling on 31-05-2022.

Looks like this integration needs to back off on the frequency of checks (or examine and honour the Retry-After header.

What version of Home Assistant Core has the issue?

2022.5.5

What was the last working version of Home Assistant Core?

2022.5.5

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Starling

Link to integration documentation on our website

https://www.home-assistant.io/integrations/starlingbank

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.sensor
Source: components/starlingbank/sensor.py:108
Integration: Sensor (documentation, issues)
First occurred: 13:20:07 (1 occurrences)
Last logged: 13:20:07

starlingbank: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update
    await task
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/starlingbank/sensor.py", line 108, in update
    self._starling_account.update_balance_data()
  File "/usr/local/lib/python3.9/site-packages/starlingbank/__init__.py", line 155, in update_balance_data
    response.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://api.starlingbank.com/api/v2/accounts/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/balance

Additional information

Extract of email from Starling...

Rate Limiting

To allow us to continue to provide a high level of service to our API consumers, we will introduce client rate limiting on our API. As is customary, we will return a HTTP 429 response with a Retry-After header whenever we reject a request due to a breach of the rate limit. We reserve the right to amend these limits as required.

Initially we will apply the following limits. The limit will be applied across all of our API endpoints.

TPPs will be given a flat limit of 100 requests per second per client_id. This limit will come into force on 1st September. Personal access tokens will have significantly more restrictive limits. These limits will come into force by 6th June. 5 requests per second 1000 requests per day

Please reach out to us via email ( developer@starlingbank.com ) or Slack ( https://updates.starlingbank.com/xxxx-xxxx-xxxxxx-xxxxx-x/c.aspx ) if you have any questions about any of these changes.

probot-home-assistant[bot] commented 2 years ago

starlingbank documentation starlingbank source (message by IssueLinks)

dullage commented 2 years ago

I'm working on this issue now.

It's been a while since I've had a dev environment setup for Home Assistant (the last time was when I first added the Starling integration) but I think it's a quick change.

von-Chaps commented 2 years ago

Oh cool, nice one. I wasn't sure if this integration was still active/supported. Thanks.

Let me know if I can help. I don't suppose there's a massive number of us using this.

von-Chaps commented 2 years ago

Nicely done @Dullage Many thanks for fixing it so quickly!