esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
404 stars 26 forks source link

Tesla vehicle command over BLE #2630

Open mongojarle opened 4 months ago

mongojarle commented 4 months ago

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.

MrBLJ commented 1 month ago

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.

mongojarle commented 1 month ago

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

nagyrobi commented 1 month ago

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

MrBLJ commented 1 month ago

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.

MrBLJ commented 1 month ago

And it looks like that someone is working on the topic already.

WeiyiWang-Cochlear commented 3 weeks ago

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.

MrBLJ commented 3 weeks ago

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

WeiyiWang-Cochlear commented 3 weeks ago

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?

MrBLJ commented 3 weeks ago

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.

WeiyiWang-Cochlear commented 3 weeks ago

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"?

MrBLJ commented 3 weeks ago

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 :

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.

WeiyiWang-Cochlear commented 3 weeks ago

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.

mongojarle commented 3 weeks ago

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

hitnrun30 commented 3 weeks ago

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?

raphmur commented 2 weeks ago

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, ...)

robin-thoni commented 3 days ago

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

mr-p666 commented 3 days ago

That's awesome! :+1:

raphmur commented 3 days ago

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: @.***>

HayderHekmat commented 1 day ago

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?

robin-thoni commented 1 day ago

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