-
Notifications
You must be signed in to change notification settings - Fork 100
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
Polling and commands fail due to Error 429 - Too Many Requests - Tesla rate limiting #961
Comments
I also received the same 429 error today. It looks like Tesla are starting to implement the rate limits which have been public for a while: According to the API response header |
Yikes! 50 commands per day? There goes my automation for excess solar charging. |
Short term, we need a PR to identify the time period specified in The issue is a user really needs to do something at this point if they are getting rate limited as it's unclear if Tesla will do anything negative, including ban users who continue to try to do things while rate limited. |
From rileymd88's link above (https://developer.tesla.com/docs/fleet-api#membership-tiers) I would guess I hit the "Command limits" of 50 reqs/day. For "Device data limits" at 1 reqs/5min we should mostly be fine, as default polling interval is at 10 minutes if I'm not mistaken. I do however agree with you on the solution to verify For Vehicle Commands however I'm not sure what to do. It's not really an option to delay the sending of the command for 24 hours. |
Same for me, automation uses data and commands every minute. Now I have to adjust manually 😕 |
You can use BLE for commands (that are not rate-limited), as you are connecting to the car directly. |
So I'm trying to understand this bug. I can no longer send commands to my car, however I'm getting data back and just as frequently as few months prior through Teslamate. Wouldn't both be hitting the same issue? |
This add on uses the new Fleet APIs which have the rate limits. Teslamate still uses the old deprecated Owners API which did not have any rate limiting in place. |
Any links/doco on how this works and how to set this up? |
Does anyone please know how or if Teslemetry is getting around this? I could be wrong but I thought it used the fleet api as well. And I’m not talking about the few entity’s you can stream with Teslemetry. After getting rate limited using this custom integration, I got my old Teslemetry hacs integration up and running again I can do a “Home Assistant core integration : update entity” service call every 15s which effectively does a force update on all Teslemetry entities and not get rate limited. |
We contacted Tesla regarding this, and they confirmed that they started to roll out their documented rate limits. That being said, we believe their implementation is buggy. For instance, we get a 429 with a This value seems odd for two reasons:
We told Tesla that we'd love to adhere to their limits (even tho some limits feel extremely small) but would need a bit more guidance. The whole We hope they come around soon to help their consumers with better advice. ¯_(ツ)_/¯ |
I also seem to be having this problem, using llamafilm's Proxy, which I only started using a few days back. I am using this for solar charging and it normally works well until sometime in the afternoon and then stops. |
the go repo for running http proxy, as well as using BLE is here: https://github.com/teslamotors/vehicle-command then I modified the method // try to use BLE
conn, err := ble.NewConnection(ctx, vin)
if err == nil {
car, err = vehicle.NewVehicle(conn, p.commandKey, p.sessions)
if err == nil {
return car, commandToExecuteFunc, nil
}
}
// if above fails, use HTTP
car, err = acct.GetVehicle(ctx, vin, p.commandKey, p.sessions) |
When blocked, I found that the mobile app still has access to the vehicle data. This also applies when my cell phone and my server have the same IP address. By using the app, I was even able to temporarily unblock my server. Does anyone have any idea whether the cell phone app isn't blocked and how? |
Thanks zlymeda. I suspect that many will have the same issues as I do, my Home Assistant server is behind CGNat and out of BLE range from the car. |
I've started getting the Error 429 this afternoon. Looking in the logs I notice I have the following entries:
Note these seem to be going on continously, this is just a selection. It seems like something is (re?)trying a poll every 10 seconds. Since the 429 started, and reading about the 50 a day limit, I've changed my polling interval from 660 seconds to 2000, which should total less than 50. I've no idea about the underlying process but could these be swamping the Tesla servers? In fact, might this mean I will never recover (these are continuing to spew out as I write this)? |
Yes, the old API used to let you access the list of vehicles and determine basic status before connecting to the vehicle without a rate limit. This was hitting Tesla's server and not your car. We do it every 10 secs. Apparently that is rate limited now. Happy to take a PR but this now means we can't detect wakeups as quickly so there might have to be a complete rearchitecture. |
Ah, thanks for the comment and link. So it looks if I set the car's Also, in my automations, I use the
For my case I don't need the car's information to be always up to date, only when I want to request it. |
Same problem here, and same goal: usage of excess solar... |
This comment has been minimized.
This comment has been minimized.
the original HTTP proxy only connects to cars via HTTP, not BLE. however, the repo contains a for my "solar excess" usage it is enough. but it is not great. the better solution would be to "know" if the car is home, and so BLE is reachable. I need to find more time to improve it. the problem, I mentioned before is that the BLE sometimes gets stuck and even context cancellation does not prevent it from blocking forever. so my workaround is: if this is detected kill the app. I run the app as a service, so killing it means restarting. I tried monitoring the car via BLE, but once it is monitoring it can't do other things, like issue command via BLE. the BLE seems not to be able to do more things at once. so I'll need some strategy to detect if the car is home (asking HA?, checking the GPS via HTTP?, ...) and based on that use BLE or HTTP. also there are issues in the official repo about reading information via BLE. right now, we can issue commands via BLE, but we don't know the state of the car and we need to use HTTP for that. if they add support for reading charge limit, charging state, ... via BLE, then we could build solar excess charging solely using BLE. |
Thanks. I am no fluent in Go, but happy to learn and to help to upgrade with this BLE integration... For what I need:
The ideal way of working (maybe) would be for this TeslaCustomIntegration to use directly (or fork and change) the vehicle-command SDK... Again, happy to help, but the starting point is not super clear for me. |
Indeed, I did not mention. I tried also to recover the keypair from the proxy, but no success. /!\ Please be aware that getting your Pi stolen or hacked will compromize your car (but you can delete the key from the car). For BLE proxy, I did not read through enough. |
Thank you - I will go fiddle with that. |
Thanks a lot for your work. It's most welcome and useful for charging our cars with excess solar power. |
Hi, The only problem is that, when i send commands to the car, i receive very ofter the error: Due to this issue i had to create a script that check if the command is successful or not, and in this case it retry it for 5 time, maybe this can be useful for someone: To change the charge setpoint of the car i call this script with arguments (like VIN and amps number). The script will cycle and and when the command is sent without error (for maximum 5 times) |
Hi all, I was searching the github issues list to find some info as yesterday my v2 API access seized to work. I did install the HTTP proxy and followed all the gory details to make FleetAPI working. So now FleetAPI works.
BTW, just as info, this is one example of the BLE measurements (of the phone signal) done by the car and sent to the phone during the authentication phase when the user tries to open the driver's door but the phone is too far so the car will not unlock: alert { All in all, I think the BLE will be good for communication with the car for charging and not only because there will be no rate limiting and no need for internet access. Hope Tesla will not try to monetize BLE as they try with the server connection. |
Super Thanks @BogdanDIA for clarification! For BLE performance, I assume using a ethernet RPi3 and leaving the full antenna for BLE should improve...? Or using an external bluetooth dongle maybe.... @andreaconfa, I like your tweak, though it just becomes specific for one command (set charge amps), which should not be a big issue as this is one of the main goals...
I really used this "BLE trial & error spamming technique" as a last option :) So it could probably be done smartly with and integration, failsafe solutions, ... Oh well |
@raphmur yes, the ethernet shoud work while having wifi disabled. |
Your post is super interesting, thanks a lot.
From what I've read, there is some kind of unicorn out there in the form of ESP32-C5 which is able to connect to 5Ghz wifi networks. However I don't think it's available yet. Based on your experience, without interference from Wi-Fi and Bluetooth (using either an RPi 5 or an Ethernet connection), what is the maximum distance at which we can place the device from the car? I am trying to decide whether I should run an Ethernet cable to my garage and use an old RPi 3, or buy a new RPi 5 (which costs at least $60 where I live) and utilize the 5 GHz Wi-Fi.
Can you expand on that :
I'm pretty confident in telling you I'm not the only one that'd be very interested in such a solution. In this case however, could we have issues between Wi-Fi and Bluetooth ? |
I've checked the ESP32 C5 few months ago but as you said it was not ready. The major work would be porting the golang to the ESP. Encrypting the FW in ESP should give a good level of protection for the car's keys. I think you need to experiment with the maximum distance you can obtain as it depends on many variables like LOS(line of sight) or not, number of other networks in the area, existing walls, etc. A for myself, I started with having a laptop at 5 meters from the car and making the BLE FleetAPI working on it I switched to rpi3 by placing it in the same spot as the laptop. It did not work as there were a lot of comm errors so that is why I switched to rpi5 on 5Ghz band. Did not check max distance, though. For car presence I started with the iBeacon HA integration which was awfully slow especially when departing from home so I decided to use ESPHome with my own implementation. Instead of using the RSSI in calculating the distance, I used the count of the iBeacon messages received from the car. This works very well in this case where the car sends tens of messages per second. When there is no message received for e.g. 3 seconds it is clear the car is not close. This worked flawlessly for more than 6 mo now. But there are other ways to change the charging parameters for the experimenters, one of them being with CAN commands. Been fiddling with CAN for sometime with an rpi/ESP32 and a OBD2 dongle, no keys needed, just 8byte messages. I don't recommend it though as I've seen Tesla changing some of the CAN commands format from time to time during the years. And also that some people say that Tesla logs strange CAN messages that do not come from MCU but from other busses of the car. On the flip side, the S3EXY buttons from enhance do the same thing by sending CAN messages instead of MCU or other devices on the buses. |
I'd check out https://github.com/pmdroid/tesla-ble and see if the API is the same. |
Thanks for everyone's contribution to this. I have created a docker container which will send commands from Home Assistant via MQTT to a car using BLE. It is useful to run on a remote device e.g. Raspberry Pi located close to where the car is parked. MQTT will auto-populate the various entities in Home Assistant, such that Buttons can be pressed (and Services called from Automations) to send commands. There is a Number entity to set the charging current. It's a first release so will need further work no doubt |
Hi,
This is awesome.
Unfortunately I already see an issue for my use-case.
I have two car (and this mean two different vins).
Maybe you can make the VIN number as a setting in home assistant instead of passing it directly to the docker container….
Do you think is possible ?
Thanks
|
Thanks @iainbullock! Looking great. Anyways, this thread is getting very long and it seems that most of us have a workaround with FleetAPI (with increased polling intervals) + BLE for frequent commands when close to the car. I suggest to close this issue as solved, marking Ian's repo as solution... @alandtse? At least until a more packaged solution raises with the full bundle HA extension: Fleet API + local BLE (on HA host) + remote BLE (on ESP or RPi), including some proximity/location sensors... Maybe switch this discussion to Discord or anything less verbose on the Internet? I just initialized this channel |
I did consider making it a HA Custom Integration, however I wanted it to on a device remote from my HA server so it could be close to the car. Please contribute to my project it would be most appreciated. |
Seems to be the old one that has been reverse engineered form the Android phone. |
Definately possible, I thought about it but decided to get this simple version released to see what comments / contributions it gets |
Thanks for the suggestion. I'm going to be away for two weeks soon, so might not get chance until i get back. It will be interesting to see what develops in the meantime |
I can try to contribute to this but I’m not sure what is the best way to do it. Using the vin as parameter in home assistant (sent via Mqtt) means that people with only one car need to also use it when not needed. Maybe a combination of fixed vin in docker (as a default one) and mqtt paremeter to override the default vin can be the way to do it. |
I think you opened an issue on my project page. Please can you repeat the question there and we can discuss it there thanks |
the discord link is not working |
edited |
It's been over a week with connecting to my model 3 through the http proxy, setting HA to only poll once an hour, getting most of the my data through Teslamate/MQTT, I haven't had any issues with occasionally interact with the vehicle. I'm interesting in messing with the BT proxy, but I think that's a winter time project. |
Do you speak German? I have just discovered this project: https://evcc.io/en/ Anyone has got elements of context? As for now @iainbullock has bundled a set of commands in a self running docker image, that connects to MQTT: https://github.com/iainbullock/tesla_ble_mqtt_docker We will probably work around these two to increase the stability and usability over BLE. |
I made https://github.com/yoziru/esphome-tesla-ble to get around this. Set up on an ESP32 and it shows up as an ESPHome device. Bonus: it works locally and offline |
What is the suggestion to not get rate limited then? Changing the polling interval from 660s/30s to something else? :) |
I only poll on demand now. For example, when I want to see my car's current stats, I use a binary helper that triggers a NodeRed routine that enables polling, updates data and then disables polling (and resets the binary helper). |
Good idea, I have to implement something loke that. But what do you do when you start charging to get the charging status updated? That is quite important for my heating/energy saving automations 🤔 You trigger a status update manually? |
I trigger an update through an automation (in my case in NodeRed). Another example is I have free electricity from Octopus Energy so I have an automation that starts charging when the free power starts and stops when it ends. |
Is there an existing issue for this?
I have read about the Fleet API and understand I may need to use it
Version of the Tesla component
3.21.0
Version of the Tesla car software
2024.14.3
Model
Model Y
Current Behavior
I setup the Fleet API via Tesla HTTP Proxy add-on a few days back. The custom integration was working at that point and I could see vehicle status and also issue commands. Today, commands stopped working but stats get updated. The integration been throwing a range of errors. Initially it was throwing UnknownException and since then I have deleted the integration, generated new Refresh Token in Tesla HTTP Proxy and set it up again. See latest log here https://pastebin.com/3R0s2Wcr - this starts from custom integration setup and until includes issue of one command.
Expected Behavior
Commands should work
Debug logs
Anything else?
I can see Running controller.update() in the logs every 10 seconds or so. Not sure if that has any implications. Polling is at the default 660 seconds.
The text was updated successfully, but these errors were encountered: