tesla-local-control / tesla-local-control-addon

Control your Tesla locally from HomeAssistant
Apache License 2.0
19 stars 2 forks source link

Unable to send key via ESP32 BT Proxy #97

Open baylanger opened 1 month ago

baylanger commented 1 month ago

I'm having this error when I try to send the key to my car. I'm using an ESP32 BT proxy which seems to see the car in the iBeacon Tracker integration. I see a device with the name that includes the S...xxx...C component of my car and includes 4 sensors including the estimated distance, which seems reasonable. Reading elsewhere, I think I can't use this add on with a BT proxy, can you confirm that please? If so, that's a shame and I wonder if it will be possible in the future? I'm happy to help if at all possible.

Originally posted by @PedroKTFC in https://github.com/tesla-local-control/tesla-local-control-addon/issues/91#issuecomment-2241277772

baylanger commented 1 month ago

Correct, it's not possible to use a proxy. The add-on uses tesla-control app written by Tesla and will likely never support Esphome BT Proxy feature.

That said, you may be interested in this project.

PedroKTFC commented 1 month ago

Thanks for the reply, I'll look at that link. Just out of curiosity, can you explain briefly why the BT proxy won't work? I know I'm being naïve but isn't BT pretty much the same irrespective of device? Also, if not BT proxy, could you suggest an alternative way of getting it to work with another device that would be visisble to HA (I can't use my HA server as it's way beyond the range to see the car).

iainbullock commented 1 month ago

I don't know why BT proxy won't work (maybe @baylanger or @raphmur can answer that one). However if you want to use a device which is remote from your HA instance, then the _docker version of the project is ideal for that purpose. https://github.com/tesla-local-control/tesla_ble_mqtt_docker

Note we will be releasing an updated v0.2.0 later today / tomorrow (probably) which is worth waiting for

PedroKTFC commented 1 month ago

Thanks. I tried the add-on and it was its failure with the BT proxy that led me to realising I couldn't use BT proxy in the way I'd hoped. If I use the docker version, do I run the MQTT broker on my HA instant and connect to it so I can, for example, run automations in HA that start and stop charging?

iainbullock commented 1 month ago

You can run MQTT broker anywhere on your network. Eg in a docker container or as a Home Assistant add on. Get that working first and then install the docker version of tesla_ble_mqtt on the remote system

baylanger commented 1 month ago

AFAIK Esphome BT Proxy works only within HA.

The tesla-control app wants direct access to the BLE adapter to talk directly to the car, it has no option to talk to do HA<-Esp BT Proxy and ... considering how the pairing works between tesla-control and the car, I doubt it's possible at all to pass via a proxy.

PedroKTFC commented 1 month ago

You can run MQTT broker anywhere on your network. Eg in a docker container or as a Home Assistant add on. Get that working first and then install the docker version of tesla_ble_mqtt on the remote system

My next problem will be finding a device to run it on! :(

iainbullock commented 1 month ago

We are finding the Bluetooth reliability is variable on different combinations of device / Bluetooth adapter. It's too early to give an absolute recommendation.

My experience to date is using Raspberry Pis. I found RPi1b with generic USB Bluetooth was not reliable. I bought a RPi3b+ and so far it has worked well. I chose this because it has built in BLE and 5GHz WiFi (2.4GHz WiFi is thought to interfere with Bluetooth). £30 off EBay

One of the other devs has a RPi4 (not sure of exact version) with no problems reported

raphmur commented 1 month ago

@PedroKTFC in fact the BT proxy is not really exposing a BT device in the HA host machine. It is only compatible with the HA bluetooth integration and interracts this way. So far I understood that:

As for now, the tesla-control tool, that is released directly by teslamotors is a bit more low level. it directly binds to the physical bluetooth in the system (thus requiring quite permissive rights) and establishes its own protocol and encryption to spead with the car. So no bueno, no compatible with BT proxy. But this project already cited by @baylanger is promising in using ESP32 as standalone Tesla relay. I tested a similar solution on ESP32 (older project) which works well, but has very limited range compared to dedicated BLE devices.

raphmur commented 1 month ago

@PedroKTFC commenting now on the bluetooth devices:

You may find this useful: https://www.home-assistant.io/integrations/bluetooth/#known-working-high-performance-adapters

PedroKTFC commented 1 month ago

Just to follow up here. I have started using ESPHome Tesla BLE with my BLE ESP32 device and it's working well. It doesn't expose as many sensors as this project which is slightly surprising as you'd imagine they both use the same API. But at least I can switch charging on and off and see a few sensors so I haven't completed wasted £6 or so on an ESP32 board! :o)