pkuehnel / TeslaSolarCharger

A software to let your Tesla charge with solar energy ☀
GNU General Public License v3.0
120 stars 21 forks source link

BLE Fail-Safe Methods #1351

Open SebastianGode opened 1 week ago

SebastianGode commented 1 week ago

Right now the BLE container just fails if the Bluetooth Device isn't responding, moved from HCI0 to HCI2 or whatever. It doesn't provide any feedback to TSC itself and as a result TSC can't control charging power and doesn't stop the charging process and empties the HomeBattery.

A Fail-Safe for this would be appreciated.

Today I had the following:

[07-Jul-2024 13:18:07.212 VRB TeslaSolarCharger.BleApi.Services.CommandLineExecutionService] Stderr Result: Error: failed to find a BLE device: can't init hci: no devices available: (hci0: can't down device: no such device)(hci1: can't up device: connection timed out)

The BLE Adapter switched again from HCI0 to HCI1 (I don't know why, sometimes just happens) and in that case it errors out. Output of hciconfig --all:

hci1:   Type: Primary  Bus: USB
        BD Address: F8:63:3F:08:60:F0  ACL MTU: 1021:4  SCO MTU: 96:6
        DOWN
        RX bytes:400941 acl:0 sco:0 events:11758 errors:0
        TX bytes:383148 acl:7266 sco:0 commands:13596 errors:1
        Features: 0xff 0xfe 0x0f 0xfe 0xdb 0xff 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
        Link policy: RSWITCH HOLD SNIFF
        Link mode: PERIPHERAL ACCEPT

In order to get it to work again I followed these steps: https://unix.stackexchange.com/a/602739 I think they require sudo access, but the container has been started with privileged: true anyways. I'd suggest doing this in case the BLE container had 3 failed attempts with such errors.

If that again doesn't help and the CLI for BLE fails again I'd suggest that TSC is stopping the charge through a Fleet-API command just to prevent that the HomeBattery is getting drained.

pkuehnel commented 1 week ago

Can you test if the steps if the steps are working when executed in the BLE container?

SebastianGode commented 1 week ago

I first need to have it in the failed state, then I can try it :)