teslamate-org / teslamate

A self-hosted data logger for your Tesla 🚘
https://docs.teslamate.org
MIT License
5.77k stars 720 forks source link

If Tesla API is down Car is showing too many requests in logs, no data being collected, so expected behaviour from teslamate #4195

Closed Nakatomi2010 closed 4 days ago

Nakatomi2010 commented 6 days ago

Is there an existing issue for this?

What happened?

One of my cars is not reporting into TeslaMate anymore. Other users appear to be experiencing the same issue here: https://github.com/teslamate-org/teslamate/discussions/4194

In log file below, car_id=1 is the car that's having a problem, which shows too many requests.

Car_id=3 is working properly.

Expected Behavior

Car's status and such should be reporting into TeslaMate.

Steps To Reproduce

Open TeslaMate and see that the car's not updating itself there.

Relevant log output

2024-09-13 12:22:01.950 [info] Version: 1.30.1
2024-09-13 12:22:02.582 [info] POST https://auth.tesla.com/oauth2/v3/token -> 200 (608.168 ms)
2024-09-13 12:22:02.582 [info] Refreshed api tokens
2024-09-13 12:22:02.589 [info] Scheduling token refresh in 6 h
2024-09-13 12:22:02.596 [info] Running TeslaMateWeb.Endpoint with cowboy 2.10.0 at :::4000 (http)
2024-09-13 12:22:02.597 [info] Access TeslaMateWeb.Endpoint at http://localhost
2024-09-13 12:22:03.314 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/1492930706631656/vehicle_data -> 429 (172.472 ms)
2024-09-13 12:22:03.314 [warning] TeslaApi.Error / %TeslaApi.Error{reason: :too_many_request, message: 41877, env: nil}
2024-09-13 12:22:03.314 [info] Starting logger for 'Bitching Betty'
2024-09-13 12:22:03.322 [info] Starting logger for 'Nagging Nora'
2024-09-13 12:22:03.338 [info] MQTT connection has been established
2024-09-13 12:22:03.635 [info] GET https://owner-api.teslamotors.com/api/1/vehicles/1492930706631656/vehicle_data -> 429 (145.610 ms)
2024-09-13 12:22:03.635 [warning] TeslaApi.Error / :too_many_request 41877
2024-09-13 12:22:03.635 car_id=1 [error] Too many request / Retry after 41877 seconds
2024-09-13 12:22:03.748 car_id=3 [info] Start / :offline

Screenshots

No response

Additional data

No response

Type of installation

Docker

Version

v13.0.1

503greg commented 6 days ago

I have the same issue, started this morning

Nakatomi2010 commented 6 days ago

To clarify a little, the same two cars talk to the custom Tesla integration in my Home Assistant instance, which uses the Fleet API.

The car that is not talking above IS talking to Home Assistant still.

So, this issue appears to be isolated to how TeslaMate talks back to Tesla.

TheDogg commented 6 days ago

Having a similar issue this morning as well

emilecantin commented 6 days ago

Same issue started for me as well this morning at 2024-09-13 04:57:18.474 UTC, says it'll retry after 68562 seconds (19 hours!)

Also did get one last night, but with a more reasonable 4000 seconds timeout: 2024-09-12 22:44:24.701 car_id=1 [error] Too many request / Retry after 4536 seconds

gurpreetz commented 6 days ago

I have the same issue as well.. started last night. I tried restarting teslamate, the car, and re-enrolling with a fresh auth token, none of which have worked so far.

Nakatomi2010 commented 6 days ago

Thinking the current Streaming/Owner API might be getting rate limited.

There are updated instructions on how to pivot to the Fleet API here: https://docs.teslamate.org/docs/guides/api/ however, it's a little unclear to me.

Fleet API is what my Home Assistant instance is using at the moment, which is still working.

Samsuuuu commented 6 days ago

I have exactly same issue, data collection failed from 09:33 am. Tried restart car, relog-in with refreshed/access tokens, problem retains.

gurpreetz commented 6 days ago

Yeah, @Nakatomi2010 I think you're right.. I came across this: https://developer.tesla.com/docs/fleet-api/support/announcements#2024-03-26-shutting-down-legacy-vehicle-api-endpoints which seems to mean they want everyone to move to the fleet API.

There seems to have been a discussion about this here as well: https://github.com/teslamate-org/teslamate/discussions/3792

Nakatomi2010 commented 6 days ago

I've tried pivoting to the Fleet API, since I've got it set up for Home Assistant, however, the instruction in the documentation are unclear.

When I add the environment variables to the docker-compose.yml and restart the instance, it seems to just reset itself to refresh and access token login, which is super confusing.

gurpreetz commented 6 days ago

Yeah, the documentation isnt clear on where those new variables need to go.

gurpreetz commented 6 days ago

Ah, I got it to work... followed https://docs.teslamate.org/docs/guides/api/#myteslamate-free and put the env variables in the teslamate section, and now things work again.

Samsuuuu commented 6 days ago

Ah, I got it to work... followed https://docs.teslamate.org/docs/guides/api/#myteslamate-free and put the env variables in the teslamate section, and now things work again.

not business fleet users, is your solution still works?

Nakatomi2010 commented 6 days ago

Can confirm, not a business fleet user. Using the MyTeslaMate process fixes it.

Would have preferred to use my own Tesla Fleet API account I have, but the instructions in the documentation don't work.

MyTeslaMate is free is you have TeslaMate, you log in with your Tesla OAuth and then pair the cars.

It'll give you a block of lines you have to add to the docker-compose.yml file, then you do a "docker compose up -d" to have it add the variables to the docker instance.

The system should then pick up where it left off.

Not sure that this is the "correct" solution, but it gets you collecting data again until someone else can review things and see what's up.

My suspicion is that Tesla wants people on the Fleet API going forward, so TeslaMate might need to look over how things are done in the near term to ensure compliance. Not sure how MyTeslaMate is going to like the additional traffic. I also don't like a random site online having access to my stuff.

Samsuuuu commented 6 days ago

Can confirm, not a business fleet user. Using the MyTeslaMate process fixes it.

Would have preferred to use my own Tesla Fleet API account I have, but the instructions in the documentation don't work.

MyTeslaMate is free is you have TeslaMate, you log in with your Tesla OAuth and then pair the cars.

It'll give you a block of lines you have to add to the docker-compose.yml file, then you do a "docker compose up -d" to have it add the variables to the docker instance.

The system should then pick up where it left off.

Not sure that this is the "correct" solution, but it gets you collecting data again until someone else can review things and see what's up.

My suspicion is that Tesla wants people on the Fleet API going forward, so TeslaMate might need to look over how things are done in the near term to ensure compliance. Not sure how MyTeslaMate is going to like the additional traffic. I also don't like a random site online having access to my stuff.

Thanks very much, it is solved now finally according to your guidance! Yes also try official Tesla Fleet API, doesn't work, display unavailable. Change to MyTeslaMate, starting also unavailable, but after about 1 min, it resumes! Thanks again!

gurpreetz commented 6 days ago

I also don't like a random site online having access to my stuff.

Agreed. When I have some time, I will try to transition to the steps listed here: https://docs.teslamate.org/docs/guides/api/#guide-to-using-the-official-tesla-api-directly-free, which bypass having MyTeslaMate being the proxy.

shivaagarwal1 commented 6 days ago

Can someone help me with where I need to add the variables? I am using Teslamate as an add-on and not through docker.

mytire commented 6 days ago

Can confirm, not a business fleet user. Using the MyTeslaMate process fixes it.

Would have preferred to use my own Tesla Fleet API account I have, but the instructions in the documentation don't work.

MyTeslaMate is free is you have TeslaMate, you log in with your Tesla OAuth and then pair the cars.

It'll give you a block of lines you have to add to the docker-compose.yml file, then you do a "docker compose up -d" to have it add the variables to the docker instance.

The system should then pick up where it left off.

Not sure that this is the "correct" solution, but it gets you collecting data again until someone else can review things and see what's up.

My suspicion is that Tesla wants people on the Fleet API going forward, so TeslaMate might need to look over how things are done in the near term to ensure compliance. Not sure how MyTeslaMate is going to like the additional traffic. I also don't like a random site online having access to my stuff.

thank you! i follow your instruction and everything is working again.

Nakatomi2010 commented 6 days ago

Can someone help me with where I need to add the variables? I am using Teslamate as an add-on and not through docker.

@shivaagarwal1 You should have a docker-compose.yml file on the machine.

Open it and you'll see a block that looks similar to this:

services: teslamate: image: teslamate/teslamate:latest restart: always environment:

You'll put the MyTeslaMate bits in at the end of the Environment section, just above "ports".

services: teslamate: image: teslamate/teslamate:latest restart: always environment:

shivaagarwal1 commented 6 days ago

Can someone help me with where I need to add the variables? I am using Teslamate as an add-on and not through docker.

@shivaagarwal1 You should have a docker-compose.yml file on the machine.

Open it and you'll see a block that looks similar to this:

services: teslamate: image: teslamate/teslamate:latest restart: always environment: - ENCRYPTION_KEY=secretkey #replace with a secure key to encrypt your Tesla API tokens - DATABASE_USER=teslamate - DATABASE_PASS=password #insert your secure database password! - DATABASE_NAME=teslamate - DATABASE_HOST=database - MQTT_HOST=mosquitto ports: - 4000:4000

You'll put the MyTeslaMate bits in at the end of the Environment section, just above "ports".

services: teslamate: image: teslamate/teslamate:latest restart: always environment: - ENCRYPTION_KEY=secretkey #replace with a secure key to encrypt your Tesla API tokens - DATABASE_USER=teslamate - DATABASE_PASS=password #insert your secure database password! - DATABASE_NAME=teslamate - DATABASE_HOST=database - MQTT_HOST=mosquitto - MyTeslaMate - Stuff - goes - here ports: - 4000:4000

Thank you for your quick reply. I am on HAOS and not running through Docker. Although, I understand that the add-ons are based on docker. I do not see the docker file in my config folder

shivaagarwal1 commented 6 days ago

I think I found it. trying to make it work now.

emilecantin commented 6 days ago

Can confirm, just adding the environment variables from MyTeslaMate makes it connect again. However, be aware it seems much slower on this config, probably due to the polling intervals (makes sense to not have these too short anyway).

I didn't mess with the streaming API stuff.

Nakatomi2010 commented 6 days ago

Can confirm, just adding the environment variables from MyTeslaMate makes it connect again. However, be aware it seems much slower on this config, probably due to the polling intervals (makes sense to not have these too short anyway).

I didn't mess with the streaming API stuff.

My understanding is that that's "by design". The delay is covered by the documentation found here: https://docs.teslamate.org/docs/guides/api

The Tesla Fleet Telemetry differs from the "Owner" streaming. By default, metrics are sent to message queues instead of a websocket as streaming did. Historical streaming could send events every second, whereas Fleet Telemetry will only send information every minute at the minimum.

emilecantin commented 6 days ago

Yeah, not something that's wrong, just something to get used to. I understand Tesla's desire to manage load on their server infrastructure, and the slower rate is more than enough for something that's only meant to keep historical stats on the car anyway.

For any real-time monitoring the official Tesla app is more appropriate.

bd-mke commented 6 days ago

I'm struggling making the change over to MyTeslaMate api work with my advanced installation with Traefik, Let's Encrypt & HTTP Basic Auth.

I've tried adding the environment variables from MyTeslaMate to the docker-compose.yml file with no success. Do I need to make the changes in the .env file instead? Or is it something with Traefik that needs to be changed?

sdit88 commented 6 days ago

I made no changes to the API and mine has returned to normal, all three cars now available. Looked back through the logs and the first time I can find rate limiting is 2024-09-10 (response code 429) which only lasted a few minutes.

cwanja commented 6 days ago

I made no changes to the API and mine has returned to normal, all three cars now available.

I waited to comment on this thread and the others as I kind of expected this might be a Tesla server side issue.

Everyone: please check your installations. If this is no longer needed, please move the issue to a discussion and close it.

TheDogg commented 6 days ago

I made no changes to the API and mine has returned to normal, all three cars now available. Looked back through the logs and the first time I can find rate limiting is 2024-09-10 (response code 429) which only lasted a few minutes.

same for me, glad it fixed itself :D

sdit88 commented 6 days ago

IMG_1044

Not my screenshot, but interesting to see another user have error 429 in the app.

gurpreetz commented 6 days ago

Hmmm, going back didnt fix it for me... (removing those newly added lines from the docker-compose file) I may have to figure out how to unpair my vehicle from https://app.myteslamate.com/fleet to get back to the owner API. Anyone have suggestions or a pointer to the docs?

sam-don commented 6 days ago

Hmmm, going back didnt fix it for me... (removing those newly added lines from the docker-compose file) I may have to figure out how to unpair my vehicle from https://app.myteslamate.com/fleet to get back to the owner API. Anyone have suggestions or a pointer to the docs?

I didn't have to unpair from myteslamate, a refresh of the TeslaMate homepage took me back to the sign in page to add a new access and refresh token that did the trick.

gurpreetz commented 6 days ago

Ah never mind.. had to re-enroll the auth token for the owner API. Works now.

gurpreetz commented 6 days ago

didn't have to unpair from myteslamate

Yeah, but I'd want to unpair so that the cloud service no longer has access - and I'm back to just streaming straight to my raspberry pi directly :)

503greg commented 5 days ago

I also reverted back to Owner API and it's working. So this was never a Teslamate issue.