iobroker-community-adapters / ioBroker.tesla-motors

ioBroker Adapter for Tesla cars and powerwalls
MIT License
8 stars 6 forks source link

Tesla implemented API rate limiting, now adapter gets blocked with HTTP/429 "Retry in 51661 seconds" #177

Open jensb opened 1 month ago

jensb commented 1 month ago

Describe the bug
See $SUBJECT. See also just every other Tesla API integration, e.g. TeslaMate: https://github.com/teslamate-org/teslamate/issues/3957

To Reproduce
Steps to reproduce the behavior:

  1. Start the adapter
  2. Look at logs, and wait

Expected behavior
Adapter should be able to poll the API the whole day. Instead, requests are rate limited according to https://developer.tesla.com/docs/fleet-api#membership-levels:

Screenshots & Logfiles

tesla-motors.0  2024-06-15 11:41:41.854 error   "Retry in 51499 seconds\n"
tesla-motors.0  2024-06-15 11:41:41.854 error   AxiosError: Request failed with status code 429
tesla-motors.0  2024-06-15 11:41:41.853 error   https://owner-api.teslamotors.com/api/1/vehicles/CENSORED/vehicle_data
tesla-motors.0  2024-06-15 11:41:41.853 error   General error
tesla-motors.0  2024-06-15 11:41:11.828 error   "Retry in 51529 seconds\n"
tesla-motors.0  2024-06-15 11:41:11.827 error   AxiosError: Request failed with status code 429
tesla-motors.0  2024-06-15 11:41:11.827 error   https://owner-api.teslamotors.com/api/1/vehicles/CENSORED/vehicle_data
tesla-motors.0  2024-06-15 11:41:11.827 error   General error

Versions:

Additional context
This may require a significant rewrite to be more conservative with requesting vehicle data. However, I am using tesla-motors information to control solar overflow charging of my vehicle, and this requires the charge state, current, battery etc. to be available in at least 30s to 1min intervals during charging. I also run TeslaMate to collect the rest of my vehicle stats.

Addressing this should be a collaborative effort and I'd be willing to help!

jheredianet commented 1 month ago

I began to experiment it since yestedar after a long drive. This morning it was working until I started to charge up the car at home, after 3 hours, now Teslamate shows teh error 429.

2024-06-15 13:55:23.957 [info] Starting logger for 'xxxxxx'
2024-06-15 13:55:23.992 [info] MQTT connection has been established
2024-06-15 13:55:24.119 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/1492931814800821/vehicle_data -> 429 (57.265 ms)
2024-06-15 13:55:24.119 [warning] TeslaApi.Error / "Retry in 43476 seconds\n"
2024-06-15 13:55:24.119 car_id=1 [error] Error / :unknown
2024-06-15 13:55:54.249 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/1492931814800821/vehicle_data -> 429 (51.010 ms)
2024-06-15 13:55:54.250 [warning] TeslaApi.Error / "Retry in 43446 seconds\n"
2024-06-15 13:55:54.250 car_id=1 [error] Error / :unknown
2024-06-15 13:56:24.373 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/1492931814800821/vehicle_data -> 429 (48.689 ms)
2024-06-15 13:56:24.374 [warning] TeslaApi.Error / "Retry in 43416 seconds\n"
2024-06-15 13:56:24.374 car_id=1 [error] Error / :unknown
2024-06-15 13:56:54.501 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/1492931814800821/vehicle_data -> 429 (49.341 ms)
2024-06-15 13:56:54.501 [warning] TeslaApi.Error / "Retry in 43386 seconds\n"
2024-06-15 13:56:54.502 car_id=1 [error] Error / :unknown
2024-06-15 13:57:22.684 [notice]     :alarm_handler: {:set, {TeslaMate.Vehicles.Vehicle_1_api_error, :fuse_blown}}
2024-06-15 13:57:24.628 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/1492931814800821/vehicle_data -> 429 (47.889 ms)
2024-06-15 13:57:24.629 [warning] TeslaApi.Error / "Retry in 43356 seconds\n"
2024-06-15 13:57:24.629 car_id=1 [error] Error / :unknown
2024-06-15 13:57:54.756 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/1492931814800821/vehicle_data -> 429 (49.707 ms)