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

API Call Limit #211

Open
vantech14 opened this issue Oct 10, 2023 · 29 comments
Open

API Call Limit #211

vantech14 opened this issue Oct 10, 2023 · 29 comments

Comments

@vantech14
Copy link

Hi,

Running the latest release, and getting an "unknown error" when logging into the API.

Anyone with the same issue? Only happening since adding a VW Up to my account.

Logger: homeassistant.components.device_tracker
Source: helpers/entity_platform.py:359
Integration: Device Tracker (documentation, issues)
First occurred: 19:39:06 (1 occurrences)
Last logged: 19:39:06

Error while setting up volkswagen_we_connect_id platform for device_tracker
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 246, in _async_update_data
return await self.update_method()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/volkswagen_we_connect_id/init.py", line 53, in async_update_data
await hass.async_add_executor_job(_we_connect.update)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/weconnect/weconnect.py", line 193, in update
self.updateVehicles(updateCapabilities=updateCapabilities, updatePictures=updatePictures, force=force, selective=selective)
File "/usr/local/lib/python3.11/site-packages/weconnect/weconnect.py", line 202, in updateVehicles
data = self.fetchData(url, force)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/weconnect/weconnect.py", line 388, in fetchData
raise RetrievalError(f'Could not fetch data. Status Code was: {statusResponse.status_code}')
weconnect.errors.RetrievalError: Could not fetch data. Status Code was: 403

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/volkswagen_we_connect_id/device_tracker.py", line 29, in async_setup_entry
await coordinator.async_config_entry_first_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 262, in async_config_entry_first_refresh
raise ex
homeassistant.exceptions.ConfigEntryNotReady: Could not fetch data. Status Code was: 403

@vantech14 vantech14 changed the title Issue with connection in UK? API Call Limit Oct 11, 2023
@vantech14
Copy link
Author

Just to follow on from this, adjusting the API calls from 30 seconds to 2 minutes fixed the issue and the errors have disappeared.

Did VW do something with the API call limit?

@bagges
Copy link

bagges commented Oct 11, 2023

Where did you change the limits? I have similar problems since a few days.

@vantech14
Copy link
Author

Where did you change the limits? I have similar problems since a few days.

@bagges you need to open custom integrations in Home Assistant:

/config/custom_components/volkswagen_we_connect_id/init.py

Here you will find:

update_interval=timedelta(seconds=XX)

XX relates to the number of seconds. Default is 30. I changed mine to 90 and it seems to work fine. 60 seconds was hit and miss.

@bagges
Copy link

bagges commented Oct 11, 2023

Thanks, I'll give it a try.

@bagges
Copy link

bagges commented Oct 11, 2023

Still no luck, I am getting 403 errors. I have two different accounts integrated with this custom component.

@PeterAndreS
Copy link

Periodically unavailable: Every five miniutes, for one to two minutes. With update_interval unchanged.
Anyone else experiencing same behaviour?

ID4 Plug Connection State changed to connected
10:55:36 - 8 minutes ago
ID4 Plug Connection State became unavailable
10:54:29 - 9 minutes ago
ID4 Plug Connection State changed to connected
10:50:26 - 13 minutes ago
ID4 Plug Connection State became unavailable
10:49:49 - 14 minutes ago
ID4 Plug Connection State changed to connected
10:45:29 - 18 minutes ago
ID4 Plug Connection State became unavailable
10:44:17 - 19 minutes ago
ID4 Plug Connection State changed to connected
10:40:12 - 23 minutes ago
ID4 Plug Connection State became unavailable
10:39:35 - 24 minutes ago
ID4 Plug Connection State changed to connected
10:35:24 - 28 minutes ago
ID4 Plug Connection State became unavailable
10:34:18 - 29 minutes ago
ID4 Plug Connection State changed to connected
10:30:10 - 33 minutes ago
ID4 Plug Connection State became unavailable
10:29:35 - 34 minutes ago
ID4 Plug Connection State changed to connected
10:25:13 - 38 minutes ago
ID4 Plug Connection State became unavailable
10:24:38 - 39 minutes ago
ID4 Plug Connection State changed to connected
10:15:34 - 1 hour ago
ID4 Plug Connection State became unavailable
10:14:26 - 1 hour ago

@vantech14
Copy link
Author

@PeterAndreS I had the same issue, and fixed this by setting the poll rate to 90 seconds.

It appears that VW have capped the rate or something. I also had issues during boot up, in that if I rebooted HA and it had polled shortly before, the integration failed to launch. The 90 second change appears to have fixed that.

@vantech14
Copy link
Author

Still no luck, I am getting 403 errors. I have two different accounts integrated with this custom component.

@bagges did you reboot HA after making the change?

@mnorrsken
Copy link

I think this messed up my app and tibber integration too. VW is really the worst. Their support is totally useless and they are changing these things constantly. Now trying with 120 seconds lets see how that works.

@vantech14
Copy link
Author

vantech14 commented Oct 12, 2023

@mnorrsken the mobile app is kit and miss, and this integration sometimes misses updates.

@mitch-dc is this integration still being maintained?

@bagges
Copy link

bagges commented Oct 13, 2023

Still no luck, I am getting 403 errors. I have two different accounts integrated with this custom component.

@bagges did you reboot HA after making the change?

for me it is working at the moment. I restarted HA after the change but I took a while to start working again.

@mnorrsken
Copy link

mnorrsken commented Oct 14, 2023 via email

@vantech14
Copy link
Author

@mnorrsken i downloaded weconnect MQTT and integrated this today via node-red. It took me a good 8 hours to do 2 cars.

For reference the minimum allowed API call limit is 300 seconds in this integration so would assume it should be the same for any other integration?

@odelma
Copy link

odelma commented Oct 16, 2023

For me the integration has fully stopped working for over a week now. I changed the polling to 120s few days agi, that did not help. Maybe I need to test with 300s. That is already 5 minutes so a bit too long to wait e.g. confirmation of climatisation starting, charging starting... But better than nothing 😅

@MCBrakel
Copy link

For me, changing the polling to 90 sec interval does do the job. Used to fail retrieving data quite often, now I have a continuous success again.

@t112013
Copy link

t112013 commented Oct 19, 2023

i just changed to 90 and it loaded on restart. it have been very unsable past two weeks i think, unsuable last 3 days.
:( i hate VW

@vantech14
Copy link
Author

@t112013 fhange to 300 seconds and see how you get on.

I changed to weconnect-MQTT and it seems to work / stable, but the minimum call rate is 300s.

@odelma
Copy link

odelma commented Oct 20, 2023

After updating requirements in manifest.json to latest weconnect.py (weconnect==0.59.1) the integration started working again, at least for the time being...

{
  "domain": "volkswagen_we_connect_id",
  "name": "Volkswagen We Connect ID",
  "config_flow": true,
  "documentation": "https://www.home-assistant.io/integrations/volkswagen_we_connect_id",
  "requirements": ["weconnect==0.59.1", "ascii_magic>=2.0.0"],
  "ssdp": [],
  "zeroconf": [],
  "homekit": {},
  "dependencies": [],
  "codeowners": [
    "@mitch-dc"
  ],
  "iot_class": "cloud_polling",
  "version": "1.0"
}

@PeterAndreS
Copy link

Connection stabel again without any changes, sinde October 19 12:00 UTC+1.
Guess volkswagen we service has also been hit by the attack, or on the move to prevent it.
Cyber incident disrupts Volkswagen’s operations

@KoalaWerewolf
Copy link

Changing update_interval to 90s has fixed it for me.

@jowi24
Copy link

jowi24 commented Oct 23, 2023

Changing update_interval to 90s has fixed it for me.

Solved the issue for me, too.

@Tassel8062
Copy link

Looks like the pre release version has had the setting altered to 45 seconds
5981529

@weakspot
Copy link

weakspot commented Nov 1, 2023

After much experimenting, I finally have the unavailable status gone and connection seems stable - for 24 hours now.
Until yesterday, the status went to "Unavailable" several times every hour. I experimented with 30, 60, 90, 120 and 180 second intervals, until yesterday I changed it to 240 seconds. This seems to have done the trick.

My most important use case for this integration is to give the car a command to start charging when electricity spot price is low, so I don't mind the looong 4 min interval.

For those still wondering how to fix their setup, here is what I did. Others have explained it much better than I ever can, but here it is:

  1. Go to Home Assistant server directory /config/custom_components/volkswagen_we_connect_id
  2. Find file called "__init__.py"
  3. Edit this row:
    update_interval=timedelta(seconds=30),
    mine is currently:
    update_interval=timedelta(seconds=240),
  4. Reload the integration (or restart HA server itself)

For stability review I used History view and particularly sensor for "state_of_charge". If the line is not continuous, you have an issue, i.e. the sensor is unavailable. If it is continuous, i.e. there is a numeric value at any given time, you're good.

@hovant
Copy link

hovant commented Nov 1, 2023

I am not using this integration but I've been following the discussion. I use another integration https://github.com/skagmo/ha_vwid with 30 second update interval and have no issues. The other integration has not all the signals and features which this has so perhaps it is not for all. I have modified it for my own purposes and added some functionality together with some other custom integrations so that I'm able to charge my ID.4 when electricity is cheap. My version is too specifically for my own purposes, so I cannot share it, and I do not have enough time to keep maintaining public version of it. It has been functioning well for almost two years already.

I do not believe that the issue is at VW cloud side as it works fine for me without any issues with 30 s interval. You should take a look how often and what API calls WeConnect-python library is making. Perhaps there is happening something what is not needed. I used to use we_connect to login and my own functions to fetch data from API but changed to ha_vwid because it is much more simpler and straight forward. WeConnect-python library has originally been developed for another purpose and there is nothing wrong with that implementation, and Till Steinbach has done great job with it. The thing is that it is far too complex for HomeAssistant use. For Homeassistant it would be better and lighter just to call VW API and return back JSON response as is, and read needed data from JSON response, and ensure that only those API calls are made which are really needed for HomeAssistant use. That is how ha_vwid custom integration is doing it.

@BaukeDeVries
Copy link

My conclusion from this discussion is that the VolksWagen-We_Connect-ID Integration is quite processor demanding. And, dependent on the number of other processor running on the same processor, the update_interval needs to be adjusted to make it run smoothly. This explains why different users have different results.
I enjoy the VolksWagen-We_Connect-ID Integration a lot and also use many of its features. In my case adjusting the interval time to 90 second works. However I am reluctant to adding more processes (Integrations) until Raspberry PI 5 has arrived.

@gmp91
Copy link

gmp91 commented Nov 24, 2023

I switched to this integration from robinostlund/homeassistant-volkswagencarnet and expierence the same error. It seems that the standard Call has been changed to 120 seconds but it's causing the erros anyway. Maybe it is because I have two e-UPs and running this on 2 different HA installations? So maybe I have to change it to 240 seconds?

@vantech14
Copy link
Author

@gmp91 the standard call in the we connect MQTT integration is 300 seconds. This works flawlessly.

@GroundAttack
Copy link

The issue is definitely caused by VW throttling back on the frequency with which requests can be made.
It's a cheap way to adjust for increased demand.

pdcastro added a commit to pdcastro/volkswagen_we_connect_id that referenced this issue Feb 9, 2024
Related to issues mitch-dc#211, mitch-dc#215 and mitch-dc#222 insofar as reducing the polling frequency
reportedly avoids WeConnect API errors (e.g. 403, 429) when the servers are busy
(API call rate limiting / throttling).
@SamuelBrucksch
Copy link

On the ID Buzz i use 90s and it works pretty well so far. However as the data in the backend seems to be very recent, I actually want to poll more often, while driving (45-60s), and less while stationary (120s or less?). Another workaround might be to define 1min during the day and 5mins during the night. Is there any way, to dynamically change the frequency? Because I would rather make this based on an automation instead of modifying the config and restarting HA.

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