Skip to content
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

Home Assistant Add-On #82

Open
stumbaumr opened this issue Jan 10, 2025 · 102 comments · May be fixed by #95
Open

Home Assistant Add-On #82

stumbaumr opened this issue Jan 10, 2025 · 102 comments · May be fixed by #95
Labels
enhancement New feature or request

Comments

@stumbaumr
Copy link

Would you be willing to add configuration files to make this docker container available as a Home Assistant add-on?
https://developers.home-assistant.io/docs/add-ons/

Some people run evcc.io as a Home Assistant Add-on - it would be conveniant to just be able to run TeslaBleHttpProxy as an Add-On as well.

@wimaha wimaha added the enhancement New feature or request label Jan 11, 2025
@Trunks1982
Copy link

Das würde mir auch gefallen!!👌

@Lenart12
Copy link
Contributor

I created a similar repo TeslaBle2Mqtt-addon that starts this proxy together with TeslaBle2Mqtt. Someone could make an addon fairly easily just for this proxy by removing the "2Mqtt" part and its related configuration.

@Trunks1982
Copy link

Trunks1982 commented Jan 29, 2025

Ich habe es gerade mal installiert aber bekomme mit meinem vorhandenen usb blenden keine Verbindung zum Auto.BLE ist aber in ha drin.

2025/01/29 17:09:55 INFO Publishing topic=tb2m/tb2m/uptime/state access path=uptime state=90 old_state=0
2025/01/29 17:09:58 ERRO Failed to publish state error="failed to get body controller state: command failed: vehicle not in range: ble: failed to scan for XP...............: context deadline exceeded"
2025/01/29 17:09:58 INFO received command=connection_status
2025/01/29 17:11:25 INFO Publishing topic=tb2m/tb2m/uptime/state access path=uptime state=180 old_state=90
2025/01/29 17:11:28 ERRO Failed to publish state error="failed to get connection status: command failed: ble: failed to scan for XP7YGCES9RB368880: skt: can't read hci socket: broken pipe"
2025/01/29 17:11:28 INFO received command=connection_status

@Lenart12
Copy link
Contributor

Does TeslaBleHttpProxy work on your hardware without the addon, running it directly? This might be problem because you are using usb dongle.

@Trunks1982
Copy link

Trunks1982 commented Jan 29, 2025

Also ich nutze im proxmox eigens eine vm nur für reine http ble und da funktioniert es mit einem usb dongle.Ich habe zwei stk.Einmal für ha vm selber und ble http vm auch.Wollte das halt nur in Ha nutzen.

Image

@Lenart12
Copy link
Contributor

Sorry, I have no idea how this works in proxmox. Im running HA Supervised with Rpi 3B+ and bluetooth that comes with it.

@Trunks1982
Copy link

Ist nicht schlimm das du das nicht weisst.Sicher ist das der usb komplett in der VM durchgereicht wird. Im Linux Vm läuft ja der proxy auch.Frage kann man nicht angeben in der programmierung auf was dr proxy alles zugreifen soll?
Also zb nicht nur hci?

@Lenart12
Copy link
Contributor

If it runs in the VM i think the problem is related to docker/homeassistant. Maybe it is not forwarding USB devices correctly. Can you try installing this addon locally and set usb: true in TeslaBle2Mqtt/config.yaml then build and try it.

@Trunks1982
Copy link

Wie meinste lokal zu installieren?
In HA OS wüsste ich nicht das ich nen compose installieren kann.

@Lenart12
Copy link
Contributor

Can you check for updates and install this testing addon:

Image

I added usb: true to see if devices get passed on correctly to docker now

@Trunks1982
Copy link

Trunks1982 commented Jan 29, 2025

sehe nur das im log: 2025/01/29 18:50:24 INFO received command=connection_status
2025/01/29 18:50:44 INFO ECDSA private key generated and saved
2025/01/29 18:50:44 INFO ECDSA public key generated and saved
2025/01/29 18:50:44 INFO BleControl initialized
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[18:51:09] INFO: Starting TeslaBle2Mqtt
2025/01/29 18:51:10 INFO Starting TeslaBle2Mqtt
2025/01/29 18:51:10 INFO TeslaBleHttpProxy undefined is loading ...
2025/01/29 18:51:10 INFO BleControl initialized

ERRO can't connect to vehicle error="failed to scan for vehicle: ble: failed to scan for XP7YGCES9RB368880: skt: can't read hci socket: broken pipe"

@Lenart12
Copy link
Contributor

Can you build my fork https://github.com/Lenart12/TeslaBleHttpProxy/ in your Linux VM and check if that works? Maybe one of my new commits breaks the proxy on your vm.

@Trunks1982
Copy link

Trunks1982 commented Jan 29, 2025

Can you build my fork https://github.com/Lenart12/TeslaBleHttpProxy/ in your Linux VM and check if that works? Maybe one of my new commits breaks the proxy on your vm.

Ich hab jetzt ihr repo neu gebildet in meiner normalen vm.Da funktioniert auch das senden des keys zum Auto und das verbinden.

2025/01/29 19:10:40 INFO TeslaBleHttpProxy 2.0.3 is loading ...
2025/01/29 19:10:40 DEBU LogLevel set to debug
2025/01/29 19:10:40 INFO TeslaBleHttpProxy httpListenAddress=:8080
2025/01/29 19:10:40 DEBU privateKeyFile loaded
2025/01/29 19:10:40 INFO BleControl initialized
2025/01/29 19:10:40 INFO TeslaBleHttpProxy is running!
2025/01/29 19:11:22 INFO ECDSA private key generated and saved
2025/01/29 19:11:22 INFO ECDSA public key generated and saved
2025/01/29 19:11:22 DEBU privateKeyFile loaded
2025/01/29 19:11:22 INFO BleControl initialized
2025/01/29 19:11:59 DEBU connecting to vehicle (A)...
2025/01/29 19:12:09 DEBU create vehicle object ...
2025/01/29 19:12:09 DEBU connecting to vehicle (B)...
2025/01/29 19:12:09 INFO Key-Request connection established
2025/01/29 19:12:09 INFO sending command=add-key-request body=map[]
2025/01/29 19:12:09 INFO Sent add-key request to XPxxxxxxxxxx. Confirm by tapping NFC card on center console.
2025/01/29 19:12:09 INFO successfully executed command=add-key-request body=map[]
2025/01/29 19:12:09 DEBU disconnect vehicle (A)
2025/01/29 19:12:09 DEBU close connection (A)
2025/01/29 19:12:20 can't accept: listner timed out

@Trunks1982
Copy link

Jetzt ist die frage ob der dongle schon in ha verwendet werden darf?
Er wird nämlich in der geräte liste angezeigt und verwendet.

@Lenart12
Copy link
Contributor

Hmm güt news and bad news :D I think we can be fairly certain the problem is with docker. I will try giving full privileges to the test addon with full_access: true. Uninstall, check for updates and reinstall please.

Image

@Trunks1982
Copy link

2025/01/29 19:30:19 INFO Starting TeslaBle2Mqtt
2025/01/29 19:30:19 INFO TeslaBleHttpProxy undefined is loading ...
2025/01/29 19:30:19 INFO BleControl initialized
2025/01/29 19:30:19 INFO TeslaBleHttpProxy is running!
2025/01/29 19:30:19 INFO Connected to MQTT client_id=tb2m_XPxxxxxxxxxxxxx
2025/01/29 19:30:19 INFO Connected to MQTT client_id=tb2m
2025/01/29 19:30:19 INFO Publishing topic=tb2m/tb2m/uptime/state access path=uptime state=0 old_state=""
2025/01/29 19:30:19 INFO Publishing topic=tb2m/status access path=status state=online old_state=""
2025/01/29 19:30:19 INFO received command=connection_status
2025/01/29 19:30:20 INFO received command=body_controller_state
2025/01/29 19:30:21 INFO connecting to Vehicle ...
2025/01/29 19:30:32 WARN failed to perform handshake with vehicle (A): vehicle rejected request: your public key has not been paired with the vehicle
2025/01/29 19:30:32 INFO retrying in 3 seconds
2025/01/29 19:30:36 ERRO can't connect to vehicle error="vehicle not in range: ble: failed to scan for XPxxxxxxxxxxxx: context deadline exceeded"
2025/01/29 19:30:40 can't accept: listner timed out
2025/01/29 19:30:43 INFO Key-Request connection established
2025/01/29 19:30:43 WARN failed to wake up car: cannot send authenticated command before establishing a vehicle session
2025/01/29 19:30:43 INFO retrying in 3 seconds
2025/01/29 19:30:46 WARN failed to wake up car: cannot send authenticated command before establishing a vehicle session
2025/01/29 19:30:46 INFO retrying in 6 seconds
2025/01/29 19:30:52 WARN max retries reached command=add-key-request body=map[] err="failed to wake up car: cannot send authenticated command before establishing a vehicle session"
L

Image

Fehler bleibt bestehen.

@Trunks1982
Copy link

Image

Das wird mir aus den Diagonosedaten von HA Bluetooth angezeigt wenn ich die json runterlade.

@Lenart12
Copy link
Contributor

Lenart12 commented Jan 29, 2025

I think bluetooth access is working now. Can you turn on debug logging in settings and show me the log again when trying to send the key. Maybe the problem is that 2Mqtt app is messing with the pairing process.

Image
Text got messed up on the screenshot but I trust you know what to do :D

@Trunks1982
Copy link

025/01/29 19:42:13 DEBU disconnect vehicle (B)
2025/01/29 19:42:13 DEBU close connection (B)
2025/01/29 19:42:13 WARN failed to perform handshake with vehicle (A): vehicle rejected request: your public key has not been paired with the vehicle
2025/01/29 19:42:13 INFO retrying in 3 seconds
2025/01/29 19:42:16 DEBU trying connecting to vehicle attempt=2
2025/01/29 19:42:16 DEBU connecting to vehicle (A)...
2025/01/29 19:42:16 DEBU scan for vehicle ...
2025/01/29 19:42:16 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-76
2025/01/29 19:42:16 DEBU dialing to vehicle ...
2025/01/29 19:42:17 DEBU create vehicle object ...
2025/01/29 19:42:17 DEBU connecting to vehicle (B)...
2025/01/29 19:42:17 DEBU start VCSEC session...
2025/01/29 19:42:17 DEBU disconnect vehicle (B)
2025/01/29 19:42:17 DEBU close connection (B)
2025/01/29 19:42:17 WARN failed to perform handshake with vehicle (A): vehicle rejected request: your public key has not been paired with the vehicle
2025/01/29 19:42:17 INFO retrying in 6 seconds
2025/01/29 19:42:23 DEBU trying connecting to vehicle attempt=3
2025/01/29 19:42:23 DEBU connecting to vehicle (A)...
2025/01/29 19:42:23 DEBU scan for vehicle ...
2025/01/29 19:42:24 ERRO can't connect to vehicle error="vehicle not in range: ble: failed to scan for XP7----------: context deadline exceeded"
2025/01/29 19:42:24 DEBU connecting to Vehicle done
2025/01/29 19:42:24 DEBU response command=body_controller_state status=503 result=false reason="vehicle not in range: ble: failed to scan for XP---------------: context deadline exceeded"
2025/01/29 19:42:24 DEBU Failed to get state error="failed to get body controller state: command failed: vehicle not in range: ble: failed to scan for XP--------------: context deadline exceeded"
2025/01/29 19:42:24 DEBU Waiting for next poll interval interval=90
2025/01/29 19:42:25 DEBU waiting for command
2025/01/29 19:42:28 can't accept: listner timed out
2025/01/29 19:43:08 DEBU connecting to vehicle (A)...
2025/01/29 19:43:08 DEBU scan for vehicle ...
2025/01/29 19:43:08 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-76
2025/01/29 19:43:08 DEBU dialing to vehicle ...
2025/01/29 19:43:13 DEBU create vehicle object ...
2025/01/29 19:43:13 DEBU connecting to vehicle (B)...
2025/01/29 19:43:13 INFO Key-Request connection established
2025/01/29 19:43:13 DEBU sending command=add-key-request body=map[]
2025/01/29 19:43:13 WARN failed to wake up car: cannot send authenticated command before establishing a vehicle session
2025/01/29 19:43:13 INFO retrying in 3 seconds
2025/01/29 19:43:16 WARN failed to wake up car: cannot send authenticated command before establishing a vehicle session
2025/01/29 19:43:16 INFO retrying in 6 seconds
2025/01/29 19:43:22 WARN max retries reached command=add-key-request body=map[] err="failed to wake up car: cannot send authenticated command before establishing a vehicle session"
2025/01/29 19:43:22 DEBU disconnect vehicle (A)
2025/01/29 19:43:23 DEBU close connection (A)

@Trunks1982
Copy link

2025/01/29 19:47:34 DEBU received handler=ProxyCommand method=GET url=/api/proxy/1/vehicles/X-----------/body_controller_state from=127.0.0.1:35464
2025/01/29 19:47:34 INFO received command=body_controller_state
2025/01/29 19:47:35 DEBU waiting for command
2025/01/29 19:47:35 INFO connecting to Vehicle ...
2025/01/29 19:47:35 DEBU trying connecting to vehicle attempt=1
2025/01/29 19:47:35 DEBU connecting to vehicle (A)...
2025/01/29 19:47:35 DEBU scan for vehicle ...
2025/01/29 19:47:36 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-86
2025/01/29 19:47:36 DEBU dialing to vehicle ...
2025/01/29 19:47:36 DEBU create vehicle object ...
2025/01/29 19:47:36 DEBU connecting to vehicle (B)...
2025/01/29 19:47:36 DEBU start VCSEC session...
2025/01/29 19:47:37 DEBU disconnect vehicle (B)
2025/01/29 19:47:37 DEBU close connection (B)
2025/01/29 19:47:37 WARN failed to perform handshake with vehicle (A): vehicle rejected request: your public key has not been paired with the vehicle
2025/01/29 19:47:37 INFO retrying in 3 seconds
2025/01/29 19:47:40 DEBU trying connecting to vehicle attempt=2
2025/01/29 19:47:40 DEBU connecting to vehicle (A)...
2025/01/29 19:47:40 DEBU scan for vehicle ...
2025/01/29 19:47:40 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-86
2025/01/29 19:47:40 DEBU dialing to vehicle ...
2025/01/29 19:47:41 DEBU create vehicle object ...
2025/01/29 19:47:41 DEBU connecting to vehicle (B)...
2025/01/29 19:47:41 DEBU start VCSEC session...
2025/01/29 19:47:41 DEBU disconnect vehicle (B)
2025/01/29 19:47:41 DEBU close connection (B)
2025/01/29 19:47:41 WARN failed to perform handshake with vehicle (A): vehicle rejected request: your public key has not been paired with the vehicle
2025/01/29 19:47:41 INFO retrying in 6 seconds
2025/01/29 19:47:47 DEBU trying connecting to vehicle attempt=3
2025/01/29 19:47:47 DEBU connecting to vehicle (A)...
2025/01/29 19:47:47 DEBU scan for vehicle ...
2025/01/29 19:47:47 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-86
2025/01/29 19:47:47 DEBU dialing to vehicle ...
2025/01/29 19:47:50 DEBU create vehicle object ...
2025/01/29 19:47:50 DEBU connecting to vehicle (B)...
2025/01/29 19:47:50 DEBU start VCSEC session...

Ich sitze im Auto und schick es los.

@Lenart12
Copy link
Contributor

beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-76

This is good. It means your usb dongle is working, so we solved the container issue and run in to a new one. I think I broke adding keys in my commits... I will look at the code and see where it goes wrong.

@Trunks1982
Copy link

Super das es mit dem dongle jetzt schonmal funktionieren würde.Bin für weitere tests bereit.Musst nur bescheid sagen.

@Lenart12
Copy link
Contributor

I think I fixed it :^) Please check v0.0.3 of the testing addon.

@Trunks1982
Copy link

Super Schlüssel erstellen hat geklappt. Jetzt bekomme ich aber noch keine Daten in Mqtt.

@Lenart12
Copy link
Contributor

Restart after adding keys. Can you show me logs again

@Trunks1982
Copy link

2025/01/29 20:18:20 DEBU waiting for command
2025/01/29 20:18:28 DEBU received handler=VehicleEndpoint method=GET url="/api/1/vehicles/XP7YGCES9RB368880/vehicle_data?endpoints=charge_state" from=192.168.0.124:48442
2025/01/29 20:18:28 INFO received command=vehicle_data body=map[endpoints:[charge_state]]
2025/01/29 20:18:28 INFO connecting to Vehicle ...
2025/01/29 20:18:28 DEBU trying connecting to vehicle attempt=1
2025/01/29 20:18:28 DEBU connecting to vehicle (A)...
2025/01/29 20:18:28 DEBU scan for vehicle ...
2025/01/29 20:18:28 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-76
2025/01/29 20:18:28 DEBU dialing to vehicle ...
2025/01/29 20:18:29 DEBU create vehicle object ...
2025/01/29 20:18:29 DEBU connecting to vehicle (B)...
2025/01/29 20:18:29 DEBU start VCSEC session...
2025/01/29 20:18:30 DEBU disconnect vehicle (B)
2025/01/29 20:18:30 DEBU close connection (B)
2025/01/29 20:18:30 WARN failed to perform handshake with vehicle (A): vehicle rejected request: your public key has not been paired with the vehicle
2025/01/29 20:18:30 INFO retrying in 3 seconds
2025/01/29 20:18:33 DEBU trying connecting to vehicle attempt=2
2025/01/29 20:18:33 DEBU connecting to vehicle (A)...
2025/01/29 20:18:33 DEBU scan for vehicle ...
2025/01/29 20:18:34 ERRO can't connect to vehicle error="vehicle not in range: ble: failed to scan for XPxxx: context deadline exceeded"
2025/01/29 20:18:34 DEBU connecting to Vehicle done
2025/01/29 20:18:34 DEBU response command=vehicle_data status=503 result=false reason="vehicle not in range: ble: failed to scan for XP7YGCES9RB368880: context deadline exceeded"
2025/01/29 20:18:34 DEBU received handler=VehicleEndpoint method=GET url="/api/1/vehicles/LRW3E7FS8PC709491/vehicle_data?endpoints=charge_state" from=192.168.0.124:51174
2025/01/29 20:18:34 INFO received command=vehicle_data body=map[endpoints:[charge_state]]
2025/01/29 20:18:35 DEBU waiting for command
2025/01/29 20:18:35 INFO connecting to Vehicle ...
2025/01/29 20:18:35 DEBU trying connecting to vehicle attempt=1
2025/01/29 20:18:35 DEBU connecting to vehicle (A)...
2025/01/29 20:18:35 DEBU scan for vehicle ...
2025/01/29 20:18:36 ERRO can't connect to vehicle error="vehicle not in range: ble: failed to scan for LRWxxxxxxx: context deadline exceeded"
2025/01/29 20:18:36 DEBU connecting to Vehicle done
2025/01/29 20:18:36 DEBU response command=vehicle_data status=503 result=false reason="vehicle not in range: ble: failed to scan for LRW3E7FS8PC709491: context deadline exceeded"
2025/01/29 20:18:37 DEBU waiting for command
2025/01/29 20:18:42 DEBU Publish state loop handler=handler for=tb2m
2025/01/29 20:18:42 INFO Publishing topic=tb2m/tb2m/uptime/state access path=uptime state=90 old_state=0
2025/01/29 20:18:42 DEBU Waiting for next poll interval interval=90
2025/01/29 20:18:44 DEBU received handler=VehicleEndpoint method=GET url="/api/1/vehicles/XP7YGCES9RB368880/vehicle_data?endpoints=charge_state" from=192.168.0.124:48442
2025/01/29 20:18:44 INFO received command=vehicle_data body=map[endpoints:[charge_state]]
2025/01/29 20:18:44 INFO connecting to Vehicle ...
2025/01/29 20:18:44 DEBU trying connecting to vehicle attempt=1
2025/01/29 20:18:44 DEBU connecting to vehicle (A)...
2025/01/29 20:18:44 DEBU scan for vehicle ...
2025/01/29 20:18:44 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-84
2025/01/29 20:18:44 DEBU dialing to vehicle ...
2025/01/29 20:18:45 DEBU create vehicle object ...
2025/01/29 20:18:45 DEBU connecting to vehicle (B)...
2025/01/29 20:18:45 DEBU start VCSEC session...

@Trunks1982
Copy link

2025/01/29 20:19:19 DEBU waiting for command
2025/01/29 20:19:19 DEBU response command=connection_status status=200 result=true reason="The command was successfully processed."
2025/01/29 20:19:19 DEBU Getting proxy response url=http://0.0.0.0:5667/api/proxy/1/vehicles/XP7YGCES9RB368880/body_controller_state
2025/01/29 20:19:19 DEBU received handler=ProxyCommand method=GET url=/api/proxy/1/vehicles/XP7YGCES9RB368880/body_controller_state from=127.0.0.1:43058
2025/01/29 20:19:19 INFO received command=body_controller_state
2025/01/29 20:19:20 DEBU waiting for command
2025/01/29 20:19:20 INFO connecting to Vehicle ...
2025/01/29 20:19:20 DEBU trying connecting to vehicle attempt=1
2025/01/29 20:19:20 DEBU connecting to vehicle (A)...
2025/01/29 20:19:20 DEBU scan for vehicle ...
2025/01/29 20:19:21 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-84
2025/01/29 20:19:21 DEBU dialing to vehicle ...
2025/01/29 20:19:23 DEBU create vehicle object ...
2025/01/29 20:19:23 DEBU connecting to vehicle (B)...
2025/01/29 20:19:23 DEBU start VCSEC session...
2025/01/29 20:19:23 DEBU disconnect vehicle (B)
2025/01/29 20:19:23 DEBU close connection (B)
2025/01/29 20:19:23 WARN failed to perform handshake with vehicle (A): vehicle rejected request: your public key has not been paired with the vehicle
2025/01/29 20:19:23 INFO retrying in 3 seconds
2025/01/29 20:19:26 DEBU trying connecting to vehicle attempt=2
2025/01/29 20:19:26 DEBU connecting to vehicle (A)...
2025/01/29 20:19:26 DEBU scan for vehicle ...
2025/01/29 20:19:26 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-86
2025/01/29 20:19:26 DEBU dialing to vehicle ...
2025/01/29 20:19:27 DEBU create vehicle object ...
2025/01/29 20:19:27 DEBU connecting to vehicle (B)...
2025/01/29 20:19:27 DEBU start VCSEC session...
2025/01/29 20:19:27 DEBU disconnect vehicle (B)
2025/01/29 20:19:27 DEBU close connection (B)
2025/01/29 20:19:27 WARN failed to perform handshake with vehicle (A): vehicle rejected request: your public key has not been paired with the vehicle
2025/01/29 20:19:27 INFO retrying in 6 seconds
2025/01/29 20:19:28 DEBU received handler=VehicleEndpoint method=GET url="/api/1/vehicles/XP7YGCES9RB368880/vehicle_data?endpoints=charge_state" from=192.168.0.124:48442
2025/01/29 20:19:28 INFO received command=vehicle_data body=map[endpoints:[charge_state]]
2025/01/29 20:19:33 DEBU trying connecting to vehicle attempt=3
2025/01/29 20:19:33 DEBU connecting to vehicle (A)...
2025/01/29 20:19:33 DEBU scan for vehicle ...
2025/01/29 20:19:34 DEBU beacon found localName=S1f367be5086602d3C addr=74:b8:39:52:93:6c rssi=-76

@Lenart12
Copy link
Contributor

Its saying your key is not paired with the vehicle. Maybe delete the keys and retry the pairing process? I'm unsure what would be other problem.

@Trunks1982
Copy link

Er meint glaub mein zweites auto.die vin kommt auch noch vor im log.

@Trunks1982
Copy link

das sagt Chatgpt:

Genau! Es scheint, als wäre der direkte Zugriff auf das Bluetooth-Gerät über /dev/hci0 in der Docker-Umgebung eine einfachere und stabilere Lösung, wenn du mit BLE arbeitest. Hier sind einige Gründe, warum der direkte Zugriff oft die bessere Wahl ist:

✅ Vorteile des direkten Gerätezugriffs (via /dev/hci0)
Keine zusätzliche Komplexität: Du umgehst den D-Bus, was zusätzliche Abhängigkeiten und Konfigurationsaufwand spart.
Stabiler: Der direkte Zugriff auf den HCI-Adapter ist oft robuster und erfordert weniger laufende Dienste oder Software, die möglicherweise fehleranfällig sind.
Echtzeit-Kommunikation: Der Adapter kann direkt mit den Bluetooth-Geräten kommunizieren, ohne durch zusätzliche Ebenen wie D-Bus blockiert zu werden.
Einfachere Fehlerbehebung: Probleme wie "Broken Pipe" oder "Can't read HCI socket" sind weniger wahrscheinlich, da keine zusätzlichen Dienste beteiligt sind, die stören könnten.
⚠️ Wann D-Bus sinnvoll sein könnte
Es gibt bestimmte Szenarien, in denen D-Bus notwendig oder vorteilhaft ist, z.B.:

Wenn du mit Bluetooth-Services wie bluetoothd arbeitest, die bereits auf D-Bus basieren (wie bei komplexeren Anwendungen oder in Systemen, die nicht direkt auf die HCI-Adapter zugreifen können).
Zentrale Verwaltung von Bluetooth-Geräten über D-Bus (wobei du auf mehrere Geräte zugreifen möchtest oder das Bluetooth-Subsystem besser abstrahieren musst).
🎯 Empfohlene Vorgehensweise
Für den direkten Zugriff auf BLE-Geräte (wie z.B. deinen Tesla): Nutze den direkten Gerätezugriff über /dev/hci0 in Docker. Das ist meist einfacher und stabiler.
Für komplexe Szenarien oder zusätzliche Verwaltung: Falls du fortgeschrittene Bluetooth-Dienste benötigst, könnte D-Bus nützlich sein, aber in deinem Fall ist das eher nicht notwendig.
Zusammenfassung
Direkt zugreifen auf das Bluetooth-Gerät ist die bevorzugte Methode für einfachere und zuverlässigere Kommunikation.
D-Bus ist nur dann notwendig, wenn du zusätzliche Features oder eine komplexere Verwaltung von Bluetooth-Diensten benötigst.
🚀 Du kannst also sicher sein, dass du mit dem direkten Zugriff auf das Gerät die beste Performance und Stabilität erreichst!

@Trunks1982
Copy link

Vielleicht sollten wir das mal so testen und direkt das gerät ansprechen:

services: tesla-ble-http-proxy: image: wimaha/tesla-ble-http-proxy:latest container_name: tesla-ble-http-proxy volumes: - ~/TeslaBleHttpProxy/key:/key # - /var/run/dbus:/var/run/dbus restart: unless-stopped privileged: true network_mode: host cap_add: - NET_ADMIN - SYS_ADMIN devices: - "/dev/hci0:/dev/hci0" # Direktzugriff auf den Bluetooth-Adapter environment: #optional logLevel: "debug" httpListenAddress: ":9090" cacheMaxAge: 180 DBUS_SYSTEM_BUS_ADDRESS: "unix:path=/var/run/dbus/system_bus_socket"

Teste das gerade in meiner anderen vm.Bis jetzt scheint es zu laufen. Aber mal abwarten.

@Lenart12
Copy link
Contributor

Lenart12 commented Feb 1, 2025

Hm that is strange because config is practically the same when comparing HA configuration and docker compose configuration. Can you test if:

  1. removing SYS_ADMIN from cap_add breaks configuration or...
  2. removing devices section breaks configuration or...
  3. if both were working also removing step 1. and 2. together

@Trunks1982
Copy link

Ohne device kann er ja bluetooth nicht mehr ansprechen richtig?
Wofür sind die anderen beiden?
Kann ich gerne nal testen und einzeln löschen.

@Lenart12
Copy link
Contributor

Lenart12 commented Feb 1, 2025

The two I listed is what is different from HA configuration. It used to work without specifying bt devices in docker and also without sys_admin.

@Trunks1982
Copy link

Ah ok.Werde es mal nach und nach testen was passiert.Aber muss sagen heute hats bis jetzt am besten funktioniert, mit den Einstellungen.

@Trunks1982
Copy link

so ich hab es gerade getestet. Ohne device kommt sofort broke pipe.
So läuft das fürs erste Reibungslos und wesentlich schnell vom Gefühl her als mit dbus usw

services:
tesla-ble-http-proxy:
image: wimaha/tesla-ble-http-proxy:latest
container_name: tesla-ble-http-proxy
volumes:
- ~/TeslaBleHttpProxy/key:/key
restart: unless-stopped
privileged: true
network_mode: host

cap_add:

- NET_ADMIN

- SYS_ADMIN

devices:
  - "/dev/hci0:/dev/hci0"  # Direktzugriff auf den Bluetooth-Adapter
environment: #optional
  logLevel: "debug"
  httpListenAddress: ":9090"
  cacheMaxAge: 180

@Trunks1982
Copy link

Muss meine Aussage revidieren. net admin und sysadmin muss an sein da läuft es.Ohne hab ich keine Verbindung hinbekommen.

@Trunks1982
Copy link

Und was mir auffällt ist wenn ich in evcc ein zweites Auto integriere und einer angeschlossen ist der andere nicht. Wird überhaupt kein Auto gefunden.Geb ich nur eins ein gehts sofort.

das ist in der nicht HA VM:

2025/02/02 10:27:33 ERRO stop retrying after 3 attempts error="failed to connect to vehicle (A): failed to find BLE beacon for LRW3E7FS8PC709491 (Se6a1153e0565dfc8C): can't scan: received scan response a8:51:ab:0c:43:3a with no associated Advertising Data packet"
2025/02/02 10:27:34 INFO connecting to Vehicle ...
2025/02/02 10:27:34 DEBU trying connecting to vehicle attempt=1
2025/02/02 10:27:34 DEBU connecting to vehicle (A)...
2025/02/02 10:27:50 WARN failed to connect to vehicle (A): failed to find BLE beacon for XPxxxxxxxxxxxxx(S1f367be5086602d3C): can't scan: received scan response a8:51:ab:0c:43:3a with no associated Advertising Data packet
2025/02/02 10:27:50 INFO retrying in 3 seconds
2025/02/02 10:27:53 DEBU trying connecting to vehicle attempt=2
2025/02/02 10:27:53 DEBU connecting to vehicle (A)...
2025/02/02 10:28:11 WARN failed to connect to vehicle (A): failed to find BLE beacon for XP7xxxxxxxxxxx(S1f367be5086602d3C): can't scan: received scan response 44:17:93:a6:5e:4a with no associated Advertising Data packet
2025/02/02 10:28:11 INFO retrying in 6 seconds
2025/02/02 10:28:17 DEBU trying connecting to vehicle attempt=3
2025/02/02 10:28:17 DEBU connecting to vehicle (A)...
2025/02/02 10:28:44 ERRO stop retrying after 3 attempts error="failed to connect to vehicle (A): failed to find BLE beacon for XP7xxxxxxxxxxxx (S1f367be5086602d3C): can't scan: received scan response 44:17:93:a6:5e:4a with no associated Advertising Data packet"
2025/02/02 10:28:45 INFO connecting to Vehicle ...
2025/02/02 10:28:45 DEBU trying connecting to vehicle attempt=1
2025/02/02 10:28:45 DEBU connecting to vehicle (A)...
2025/02/02 10:29:00 WARN failed to connect to vehicle (A): failed to find BLE beacon for LRWxxxxxxxxxxxxxx(Se6a1153e0565dfc8C): can't scan: received scan response 44:17:93:a6:5e:4a with no associated Advertising Data packet
2025/02/02 10:29:00 INFO retrying in 3 seconds
2025/02/02 10:29:03 DEBU trying connecting to vehicle attempt=2
2025/02/02 10:29:03 DEBU connecting to vehicle (A)...
2025/02/02 10:29:18 WARN failed to connect to vehicle (A): failed to find BLE beacon for LRWxxxxxxxxxxxxxx(Se6a1153e0565dfc8C): can't scan: Command Disallowed
2025/02/02 10:29:18 INFO retrying in 6 seconds
2025/02/02 10:29:25 DEBU trying connecting to vehicle attempt=3
2025/02/02 10:29:25 DEBU connecting to vehicle (A)...

@Lenart12
Copy link
Contributor

Lenart12 commented Feb 5, 2025

Hello @Trunks1982. I have added a new feature to the proxy, which will now allow specifiying which bluetooth adapter to use via its mac address. This means it is no longer a problem if you have multiple adpaters or it is on hci1.

Image

@Trunks1982
Copy link

Super ich werde es testen und berichten.

@Trunks1982
Copy link

Bei mir startet die website nicht und ich kann hci0 nicht bennenen, da meckert er sofort.

@Lenart12
Copy link
Contributor

Lenart12 commented Feb 5, 2025

You dont name "hciX" but the BD address (MAC) of the adapter. You can get it with hciconfigor bluetoothctl list. Probably why it doesn't start. You can also leave it empty and it will autodetect.

@Trunks1982
Copy link

Image

Startet nicht sagt auch bad gateway. Hab nur mqtt daten und vin eingegeben

@Lenart12
Copy link
Contributor

Lenart12 commented Feb 5, 2025

Can you please install this addon and report what it shows inside debug logs:

Image

@Trunks1982
Copy link

Wo finde ich das?
Mit updates kommt nichts.

@Trunks1982
Copy link

Ah jetzt ist es aufgetaucht.

@Trunks1982
Copy link

Image

@Lenart12
Copy link
Contributor

Lenart12 commented Feb 5, 2025

Hmm.. To me this indicates no HCI device is passed to your container.

@Trunks1982
Copy link

Image

Mit eingegebenen ble device

@Trunks1982
Copy link

Image

@Lenart12
Copy link
Contributor

Lenart12 commented Feb 5, 2025

Can you try to disable one of the device in HA and then try again with BLE test tool?

@Lenart12
Copy link
Contributor

Lenart12 commented Feb 5, 2025

Image

Just checking, you did disable protection mode right?

@Trunks1982
Copy link

Ja der modus ist aus.Gerät hatte ich gerade einmal rausgeschmissen.Der stick ist auf hci 1.

Image

@Trunks1982
Copy link

Muss nochmal gucken wenn ich später zu hause bin.

@Lenart12
Copy link
Contributor

Lenart12 commented Feb 5, 2025

Hmm now both adapters show up. Did you change anything? input/output error normaly indicates hardware issue or multiple software interfearing with eachother. Maybe simple restart and unplugging adapters will fix it 🤞

@Trunks1982
Copy link

So der stick wurde umgesteckt aber wird vom addon nicht gefunden auf hci1.In Ha funktioniert er.

@Trunks1982
Copy link

Image

Oh man jetzt hab ich mal aus Spass das erste Gerät eingegeben bei dem Addon und siehe da es ging jetzt

@Trunks1982
Copy link

Trunks1982 commented Feb 5, 2025

Zu früh gefreut.Jetzt läuft gar nichts mehr mit dem addon.Kann es auch nicht mehr stoppen, weil er meint da läuft noch was im hintergrund. Irgendwie ist es jetzt schlechter geworden.

Das addon bringt mein ganzes System durcheinander.Konnte auch nicht mehr HA updaten.

@Trunks1982
Copy link

Trunks1982 commented Feb 7, 2025

Hier steht glaub alles geschrieben wie HA das macht: https://www.home-assistant.io/integrations/bluetooth/
Mir ist aber auch aufgefallen was ich nicht wusste das ich intern auch Bluetooth habe.Aber damit läuft der proxy aber auch nicht.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants