Open tadly opened 3 weeks ago
Yes there are plans to do this, but it is very difficult, and it will take time. I will also need a way to install a private key on vehicles, which is likely going to require a bluetooth implementation, which I have also started for Home Assistant.
Did a quick google to get a better understanding on the whole key topic. We would need to install the public-key part (not private) on the vehicle. This medium articel outlines it quite well.
For protocol, the relevant part of the article:
Step 1 :: Generate the private key
openssl ecparam -genkey -name prime256v1 -noout > private.pem
Step 2 :: Generate the public key
openssl ec -in private.pem -pubout > public.pem
Step 3 :: Add the public key with the car
./tesla-control -vin {VIN} -ble add-key-request {path_to_the_public_key_along_with_the_public_key_file_name} {ROLE} {FORM_FACTOR}
VIN — Vehicle Identification Number
ROLE — One of: owner, driver
FORM_FACTOR — One of: nfc_card, ios_device, android_device, cloud_key
A sample command to add a BLE key looks like the below -
./tesla-control -vin 7ABCGDEE123ABC555 -ble add-key-request public.pem owner cloud_key
When the command is issued, a successful request will return the following response.
Sent add-key request to 7ABCGDEE123ABC555. Confirm by tapping NFC card on center console.
Did a quick google to get a better understanding on the whole key topic. We would need to install the public-key part (not private) on the vehicle. This medium articel outlines it quite well.
Yes, but that's written in Go and the only Python implementation hasn't been updated for ~2 years and no longer works. I've spent most of the day today working on it and while I can get the public key installed that's about as far as I have it working.
I may just give up on the Bluetooth implementation and resort to giving people instructions to use Tesla's tools.
Oh I see. You wanted it to be part of this project (makes sense). For a first iteration, just to get command signing to work, relying on Tesla's tool wouldn't be that bad IMO. Key-generation and installation needs to be done only once so... :)
Well the bluetooth side will live in https://github.com/Teslemetry/python_tesla_bluetooth but it creates the private key that this library could then use.
So really now the biggest blocker is that the only command signing implementation ive seen that works is either in C# or Go, and I need it in Python. It'll be the next thing I try attempt.
Mind sharing the go project? Translating the logic to python shouldn't be that hard I think. Maybe I can help :)
https://github.com/teslamotors/vehicle-command/blob/main/cmd/tesla-http-proxy/main.go
I have started the library side implementation here: https://github.com/Teslemetry/python-tesla-fleet-api/blob/main/tesla_fleet_api/vehiclesigned.py
I got pretty close to a working implementation on flash_lights tonight. Just the HMAC signature to go, so it's realistic that I could get this in for 2024.11
I love how you went from
...but it is very difficult, and it will take time
to
IT WORKS
in just 3 days. Thank you so much for this. Gets me really excited to finally automate some stuff with my tesla
I suffer from shiny object syndrome. I started making progress and felt like It was actually acheivable. I have working:
Just the matter of writting all the protobuf defintions for the other Infotainment commands and then a lot of exception handling.
I suffer from shiny object syndrome.
Sounds to me like you got into some kind of flow. I love when that happens :)
Given the commit history, you've been chipping away. Congrats on getting all that figured out and thanks again for doing so. Really appreciate it man :)
Discussions aren't enabled and there's no issue for this yet so here I go...
Home-Assistant just added a bunch of features to the tesla integration which is based on this module. For my m3 highland, command signing seems to be required.
Are there plans on adding support for this?
I don't know how difficult this would be so excuse me if I sound ignorant.