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

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

Addon intermittently working #106

Closed guyank closed 9 hours ago

guyank commented 3 weeks ago

Hi,

I had lots of problems pairing the key with my car as when I pressed 'Deploy Key' nothing appeared on the screen to confirm. eventually I managed by sitting in the car repeatedly pressing it until it worked. Now, the sending of commands and reading or presence is very intermittent. For example, here is my history presence for the last 24 hours:

IMG_9F384FEF00F0-1

I arrived at 1750 and the was out between about 0800 and 0810, but its only recording the car at home for very short periods. When I send a command, the following is what I see in the logs:

[10:59:05] INFO: Received MQTT message; topic:tesla_ble/LRW3F7FS2NC505232/command msg:honk vin:LRW3F7FS2NC505232 cmd:command [10:59:05] NOTICE: Attempt 1/5 sending Honk horn to vin:LRW3F7FS2NC505232 command:honk [10:59:05] ERROR: tesla-control send command:honk to vin:LRW3F7FS2NC505232 failed exit status 1. [10:59:05] ERROR: teslaCtrlSendCommand; Error: failed to find a BLE device: can't init hci: no devices available: [10:59:05] NOTICE: teslaCtrlSendCommand; Retrying in 5 seconds [10:59:10] NOTICE: Attempt 2/5 sending Honk horn to vin:LRW3F7FS2NC505232 command:honk [10:59:10] ERROR: tesla-control send command:honk to vin:LRW3F7FS2NC505232 failed exit status 1.

I assumed it was an issue with BLE range, so have had the Pi4B that I am using right next to the car and this doesn't seem to have helped, so any ideas as to where I can go next?

Thanks

raphmur commented 3 weeks ago

Hello @guyank,

It really looks like a range / signal power issue. Are you using the iBeacons integration? How strong is the signal reported?

Are you using other bluetooth or BLE app on Home Assistant? Are you running HAOS or Virtual Machine? Is your Pi in an enclosure? How hot is the room? I had issue when the Wifi/BLE chip got hot. I now use an actively cooled case. You can also try rebooting (physical reboot) of the Pi to see if it gets better.

guyank commented 3 weeks ago

Sorry, as usual, I've not supplied enough information!

What do you mean by the iBeacons integration? I take it you mean the Docker version rather than Core? I'm running HASSOS on a VM on an Unraid server, with no bluetooth. The Pi4 is only running this in the Docker version. I initially tried it in an ArgonOne enclosure, but wondered whether this was the cause, so its now out of this. Its in the window of a room that isn't very warm, so I don't think the actual room is contributing to it.

When I run a BLE scan using bluetoothctl, its returning an RSSI of between about -47 and -56.

Rebooting the Pi does cause it to show as Home, then it appears away again within about a minute.

guyank commented 3 weeks ago

I don't know whether this is unusual, but in the log I get:

vin:LRWXXXXXX ble_ln:SfbXXXXX match:(Sfb7XXXXX|MAC) presence detected

even when its showing the car as away

iainbullock commented 2 weeks ago

You should see something like this repeating when presence is detected:

2024-08-27T05:19:36.916034295Z vin:LRWXXXXXXX403 ble_ln:Sa27XXXXXXXe18C match:(Sa27XXXXXXe18C|MAC) presence detected

Then when I drive my car away I get this, with the last line repeating until the car returns:

2024-08-27T05:21:47.470089651Z vin:LRWXXXXXXX03 ble_ln:Sa27XXXXXXX18C match:(Sa2XXXXXX18C|MAC) presence detected
2024-08-27T05:23:58.038254017Z vin:LRWXXXXXXX03 ble_ln:Sa27XXXXXXX18C presence not expired
2024-08-27T05:26:08.589560808Z vin:LRWXXXXXXX03 presence has expired, set presence OFF

Then when the car returns I get this (with the last line repeating):

2024-08-27T17:00:23.985121453Z vin:LRWXXXXXXX03 presence has expired, set presence OFF
2024-08-27T17:02:34.597546936Z vin:LRWXXXXXX403 ble_ln:Sa27XXXXXXX8C match:(Sa27XXXXXXX18C|4MAC) presence detected
2024-08-27T17:02:34.597851517Z vin:LRXXXXXX403 presence has expired, set presence ON
2024-08-27T17:04:45.196908873Z vin:LRWXXXXXX403 ble_ln:Sa27XXXXXX18C match:(Sa27XXXXXXX18C|MAC) presence detected

Note my variables related to presence detection are set as follows:

PRESENCE_DETECTION_LOOP_DELAY=120
PRESENCE_DETECTION_TTL=240

What are yours set to?

raphmur commented 4 days ago

@guyank could you solve your issue? I had similar behaviour after leaving home for 3 weeks. Had to restart the addon for it to detect the car had come back

guyank commented 2 days ago

You should see something like this repeating when presence is detected:

2024-08-27T05:19:36.916034295Z vin:LRWXXXXXXX403 ble_ln:Sa27XXXXXXXe18C match:(Sa27XXXXXXe18C|MAC) presence detected

Then when I drive my car away I get this, with the last line repeating until the car returns:

2024-08-27T05:21:47.470089651Z vin:LRWXXXXXXX03 ble_ln:Sa27XXXXXXX18C match:(Sa2XXXXXX18C|MAC) presence detected
2024-08-27T05:23:58.038254017Z vin:LRWXXXXXXX03 ble_ln:Sa27XXXXXXX18C presence not expired
2024-08-27T05:26:08.589560808Z vin:LRWXXXXXXX03 presence has expired, set presence OFF

Then when the car returns I get this (with the last line repeating):

2024-08-27T17:00:23.985121453Z vin:LRWXXXXXXX03 presence has expired, set presence OFF
2024-08-27T17:02:34.597546936Z vin:LRWXXXXXX403 ble_ln:Sa27XXXXXXX8C match:(Sa27XXXXXXX18C|4MAC) presence detected
2024-08-27T17:02:34.597851517Z vin:LRXXXXXX403 presence has expired, set presence ON
2024-08-27T17:04:45.196908873Z vin:LRWXXXXXX403 ble_ln:Sa27XXXXXX18C match:(Sa27XXXXXXX18C|MAC) presence detected

Note my variables related to presence detection are set as follows:

PRESENCE_DETECTION_LOOP_DELAY=120
PRESENCE_DETECTION_TTL=240

What are yours set to?

I'm getting the same messages as you, but presence changes to away again, oddly with the same repeating message as you:

vin:LRXXXXXXXXXXXXXX ble_ln:SfXXXXXXXXXXXXXX match:(SfXXXXXXXXXXXXXX) presence detected
vin:LRXXXXXXXXXXXXXX presence has expired, set presence ON
vin:LRXXXXXXXXXXXXXX ble_ln:SfXXXXXXXXXXXXXX match:(SfbXXXXXXXXXXXXXX) presence detected

My variables are the same.

@guyank could you solve your issue? I had similar behaviour after leaving home for 3 weeks. Had to restart the addon for it to detect the car had come back

I haven't managed to solve it yet.

iainbullock commented 1 day ago

I was away with my car for a week recently and it worked ok. I'm running _docker version. I can't replicate so struggling to provide further advice on this one

guyank commented 11 hours ago

I think there may be 2 separate problems. Looking at the presence detection first, the log from the Pi shows:

vin:LRXXXXXXXXXXXXXX ble_ln:SfXXXXXXXXXXXXXX match:(SfXXXXXXXXXXXXXX) presence detected
vin:LRXXXXXXXXXXXXXX ble_ln:SfXXXXXXXXXXXXXX match:(SfXXXXXXXXXXXXXX) presence detected
vin:LRXXXXXXXXXXXXXX ble_ln:SfXXXXXXXXXXXXXX match:(SfXXXXXXXXXXXXXX) presence detected

However, the HA add-on log shows:

[11:33:00] INFO: vin:LRWxxxxxxxxxxxx presence has expired, set presence OFF
[11:35:11] INFO: vin:LRWxxxxxxxxxxxx presence has expired, set presence OFF
[11:37:21] INFO: vin:LRWxxxxxxxxxxxx presence has expired, set presence OFF

So, for some reason it appears that the MQTT messages aren't always getting through. I've double checked the docker install on the Pi matches the add-on, so I'm at a loss of what to look at next. I have MQTT working without problem for a number of other integrations.

guyank commented 9 hours ago

Following on from this, after much moving of the Pi, tweaking of network settings and repeatedly trying it, I seem to have consistent control via BLE. I haven't found what the underlying cause was. I still don't get accurate presence detection, but I was really only using this as an indicator of intermittent connectivity. Thanks for the help

iainbullock commented 9 hours ago

Thanks for letting me know