feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

Tesla vehicle command over BLE

Open mongojarle opened this issue 1 year ago • 27 comments

tes Describe the problem you have/What new integration you would like

Support for local control of Tesla vehicle. Send commands to the car (i.e unlock/lock, start charge, set charge amps). Teslas repo: https://github.com/teslamotors/vehicle-command (everything below "Using the HTTP proxy" is not necessary for local BLE control). Commands over BLE: https://github.com/teslamotors/vehicle-command/tree/main/cmd/tesla-control

Please describe your use case for this integration and alternatives you've tried:

ESP in garage, connected to vehicle over BLE as well as local wifi. Sending commands to ESP over MQTT/HA to start/stop charging and set charge amp. Was using Tesla "node" in nodered earlier, but Tesla changed their API, so it no longer works, with little hope for fixing (https://github.com/onokje/node-red-contrib-tesla). Local control over BLE also bypasses the requirements for internet and the use of Teslas API.

Additional context

Gathering information from the car from Teslas API is not as strict as controlling the car. So getting info from the car over BLE is not necessary, or possible I think. Teslamate still works for logging car, also this is a plus, since logging also works on trips, outside of BLE/wifi range. Needs to control the car elsewhere than garage/BLE coverage may just as well be done through the Tesla app.

mongojarle avatar Feb 28 '24 19:02 mongojarle

Was using Tesla "node" in nodered earlier, but Tesla changed their API, so it no longer works

That's definitely correct. We can make use of a proxy to keep sending commands but there's a major issue : Tesla introduced a cap on the number of commands that can be sent per car each day. For those of us who'd like to optimize their solar power production by making use of commands like start/stop charging and set charge amp, this is a big limitation.

Briochorama avatar Jun 04 '24 11:06 Briochorama

Tesla introduced a cap on the number of commands that can be sent per car each day.

Another good reason to why just use BLE, as it is local directly to the car, not through any of Teslas servers.

Here is a project using python: https://github.com/kaedenbrinkman/PyTeslaBLE

mongojarle avatar Jun 04 '24 12:06 mongojarle

Someone should just make a Home Assistant custom component out of it, and just use ESPHome's bt_proxy.

nagyrobi avatar Jun 04 '24 12:06 nagyrobi

Someone should just make a Home Assistant custom component out of it, and just use ESPHome's bt_proxy.

Someone should indeed. Question is who's capable and willing to ? I'm currently reading on the topic, and found some interesting resources on the subject.

The question now is how do we convert this into an esphome module/integration (not even sure how to call it) ? For now, it's beyond my knowledge. Not sure ChatGPT will know much about this either.

Briochorama avatar Jun 04 '24 13:06 Briochorama

Definitely would like to have this, for exactly the same reason of controlling charging amps to make use of solar power. The new fleet API has ridiculous rate limit that can't be used for this purpose.

WeiyiWang-Cochlear avatar Jun 12 '24 11:06 WeiyiWang-Cochlear

Definitely would like to have this, for exactly the same reason of controlling charging amps to make use of solar power. The new fleet API has ridiculous rate limit that can't be used for this purpose.

This is quite fresh and new, but it's working. https://github.com/iainbullock/tesla_ble_mqtt_docker

Briochorama avatar Jun 12 '24 11:06 Briochorama

Definitely would like to have this, for exactly the same reason of controlling charging amps to make use of solar power. The new fleet API has ridiculous rate limit that can't be used for this purpose.

This is quite fresh and new, but it's working. https://github.com/iainbullock/tesla_ble_mqtt_docker

Wow! Nice find! I was hoping to get it work with an ESP32 (for its low power consumption) and place it around the car, but a r-Pi is fine as well, at least for now. Did you have it running already?

WeiyiWang-Cochlear avatar Jun 12 '24 11:06 WeiyiWang-Cochlear

Definitely would like to have this, for exactly the same reason of controlling charging amps to make use of solar power. The new fleet API has ridiculous rate limit that can't be used for this purpose.

This is quite fresh and new, but it's working. https://github.com/iainbullock/tesla_ble_mqtt_docker

Wow! Nice find! I was hoping to get it work with an ESP32 (for its low power consumption) and place it around the car, but a r-Pi is fine as well, at least for now. Did you have it running already?

Yes it's up and running. The number of commands is limited and there are minor issues for now, but I guess the hardest part is done (adding the key to the vehicule was painless, and commands are received well).

I wrote a tutorial to set this up (doc is clear but I think some users will have difficulties), use your browser to translate to english: https://forum.hacf.fr/t/envoyer-des-commandes-a-sa-tesla-via-mqtt-ble/43348.

Esphome support would be nice but this is out of my reach.

Briochorama avatar Jun 12 '24 11:06 Briochorama

Definitely would like to have this, for exactly the same reason of controlling charging amps to make use of solar power. The new fleet API has ridiculous rate limit that can't be used for this purpose.

This is quite fresh and new, but it's working. https://github.com/iainbullock/tesla_ble_mqtt_docker

Wow! Nice find! I was hoping to get it work with an ESP32 (for its low power consumption) and place it around the car, but a r-Pi is fine as well, at least for now. Did you have it running already?

Yes it's up and running. The number of commands is limited and there are minor issues for now, but I guess the hardest part is done (adding the key to the vehicule was painless, and commands are received well).

I wrote a tutorial to set this up (doc is clear but I think some users will have difficulties), use your browser to translate to english: https://forum.hacf.fr/t/envoyer-des-commandes-a-sa-tesla-via-mqtt-ble/43348

Thanks! I'll give it a try later today after work. Should be rather straight forward as I understood. I managed already earlier to send commands to the car from my Mac with the car in it's bluetooth range.

What do you actually mean by "the number of commands is limited"?

WeiyiWang-Cochlear avatar Jun 12 '24 11:06 WeiyiWang-Cochlear

Definitely would like to have this, for exactly the same reason of controlling charging amps to make use of solar power. The new fleet API has ridiculous rate limit that can't be used for this purpose.

This is quite fresh and new, but it's working. https://github.com/iainbullock/tesla_ble_mqtt_docker

Wow! Nice find! I was hoping to get it work with an ESP32 (for its low power consumption) and place it around the car, but a r-Pi is fine as well, at least for now. Did you have it running already?

Yes it's up and running. The number of commands is limited and there are minor issues for now, but I guess the hardest part is done (adding the key to the vehicule was painless, and commands are received well). I wrote a tutorial to set this up (doc is clear but I think some users will have difficulties), use your browser to translate to english: https://forum.hacf.fr/t/envoyer-des-commandes-a-sa-tesla-via-mqtt-ble/43348

Thanks! I'll give it a try later today after work. Should be rather straight forward as I understood. I managed already earlier to send commands to the car from my Mac with the car in it's bluetooth range.

What do you actually mean by "the number of commands is limited"?

At this stage, you can only :

  • Start/Stop charging
  • Open/Close the trunk
  • Set charge current (min 5A)

There's no limit on the amount of commands you can send (poor choice of words in my previous message sorry).

More commands can be added, but from what I've understood the author is on holiday for now.

As for the charge current issue, it's under scrutiny. I'm confident it'll be fixed.

Briochorama avatar Jun 12 '24 11:06 Briochorama

Aha got it. Setting charging current is my urgent need at the moment so that's fine. Adding supports to other commands wouldn't be complex either I assume, considering that the Tesla BLE api does support a wide range of commands.

WeiyiWang-Cochlear avatar Jun 12 '24 12:06 WeiyiWang-Cochlear

Some WIP here as well: https://github.com/robin-thoni/tesla-ble-esphome

mongojarle avatar Jun 12 '24 13:06 mongojarle

Some WIP here as well: https://github.com/robin-thoni/tesla-ble-esphome

So for this to work you just need an ESP 32 whatever setup in ESPhome, I mean it does make it local, so that is good, my biggest thing I want to do is know if it is charging and set the temperature to go on in the morning or when I'm leaving. Is that possible with this eventually?

hitnrun30 avatar Jun 15 '24 17:06 hitnrun30

Hi there We (team of 3) are also working on a custom ha Addon: https://github.com/tesla-local-control/tesla-local-control-addon

We will merge with this one as well https://github.com/iainbullock/tesla_ble_mqtt_docker

Today the HA Addon is working, relatively stable, ans brings you command buttons to operate your solar charge, and all the others (AC, windows, trunk, honk, ...). It also implements a presence scanner. But not capability yet to read car values.

This is fairly new so moving quickly. It can be used as is in home assistant using built in bluetooth (eg. on RPi) or can be deployed as standalone docker. It then populates MQTT entities.

Please come and comment there to make thing progress. In the next steps we have: bluetooth proxy (esp)... It would make a lot of sense to empack different variants in the same place (python variants, esp standalone, ...)

raphmur avatar Jun 24 '24 22:06 raphmur

Some WIP here as well: https://github.com/robin-thoni/tesla-ble-esphome

Hey guys, here's a working demo (with sound) (video has to be <10Mb, so shitty quality):

https://github.com/esphome/feature-requests/assets/9640353/cc02a415-8275-4b3c-955c-57a93effa81f

My repo is up to date if you want to test, with instructions in the README

robin-thoni avatar Jul 05 '24 14:07 robin-thoni

That's awesome! :+1:

mr-p666 avatar Jul 05 '24 16:07 mr-p666

Super nice yes 👍

Le ven. 5 juil. 2024, 18:03, mr-p666 @.***> a écrit :

That's awesome! 👍

— Reply to this email directly, view it on GitHub https://github.com/esphome/feature-requests/issues/2630#issuecomment-2211115128, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASFC4JL7VA3V75BRJNN3R3ZK27VBAVCNFSM6AAAAABD6UJBLCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJRGEYTKMJSHA . You are receiving this because you commented.Message ID: @.***>

raphmur avatar Jul 05 '24 16:07 raphmur

It will be nice if there some instruction how to use EspHome add-on in HA to program an ESP. @robin-thoni: did you use the evcc or HA with your device?

HayderHekmat avatar Jul 07 '24 14:07 HayderHekmat

It will be nice if there some instruction how to use EspHome add-on in HA to program an ESP.

That's out of scope. There's already the official doc for this.

did you use the evcc or HA with your device?

I'm using HA

robin-thoni avatar Jul 07 '24 17:07 robin-thoni

@andig and @robin-thoni, I have successfully installed BLE-esphome ( https://github.com/robin-thoni/tesla-ble-esphome) . I configured also the evcc but, I got always those error.

ERROR 2024/07/14 17:34:09 max charge current 4A: Post "http://192.168.178.xxx:8080/api/1/vehicles/XX/command/set_charging_amps": dial tcp 192.168.178.xx:8080: connect: connection refused

I stacked first with similar issue in #14616 and after many restart. Then the evcc started to try to access the BLE proxy. But this issue happening many times of not considering the proxy command.

ping 192.168.178.xx

Pinging 192.168.178.xx with 32 bytes of data: Reply from 192.168.178.xx: bytes=32 time=274ms TTL=255 Reply from 192.168.178.xx: bytes=32 time=80ms TTL=255 Reply from 192.168.178.xx: bytes=32 time=90ms TTL=255 Reply from 192.168.178.xx: bytes=32 time=94ms TTL=255

HayderHekmat avatar Jul 14 '24 16:07 HayderHekmat

I'm not sure what you're trying to do, since I've never used evcc. The only thing I can tell you is that setting the max current charge limit is currently not supported in tesla-ble-esphome, as it's not part of VCSEC, which is the only supported component at the moment

robin-thoni avatar Jul 14 '24 16:07 robin-thoni

I've added support for UniversalMessage and both the VSSEC + Infotainment domain in https://github.com/yoziru/tesla-ble And then integrated into an ESPHome project at https://github.com/yoziru/esphome-tesla-ble Work-in-progress but works 🤷

yoziru avatar Jul 16 '24 22:07 yoziru

Good job! Can't wait to test this!

robin-thoni avatar Jul 17 '24 07:07 robin-thoni

Q for those using RPi with a Tesla: how well does it work for you?

I am able to hang and crash a RPi with the BLE traffic, about once per day or two. It's not really usable. Happening with both RPi4 and Zero 2 W.

I'm now looking into using ESP32, because that one can at least restart if it hangs...

LubosD avatar Aug 31 '24 07:08 LubosD

when it works it works really well. But I have to restart the raspberry once per week because of error 429. I don't know whether it is evcc or the ble proxy

burschi87 avatar Sep 05 '24 06:09 burschi87

Hi all, I'm interested in getting this working with an ESP32/ bluetooth proxy. I've seen these projects exist: https://github.com/yoziru/esphome-tesla-ble or https://github.com/robin-thoni/tesla-ble-esphome Is that possible to combine something like this with EVCC and its tesla commandproxy? Thanks!

BM183 avatar Oct 21 '24 12:10 BM183