-
Notifications
You must be signed in to change notification settings - Fork 4
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
body-controller-state: Error: failed to find a BLE device: .... #142
Comments
Updates:
Maybe what is happening:
Next steps:
|
Action: Provide environment variables for tesla-control -command-timeout -connect-timeout, and loop delay in poll_state_loop() parameters so users can adjust to match their requirements I have implemented, and settled on the following which seem stable for my set up (RPi3b+, car 1.5 metres away):
|
I may have spoken too soon. Just had a lock up after car being away for 4 hours. Investigating...
Everything is going well with a successful call every 60 secs. The last successful call is at 14:10:53, then next message on the standard error is '2025/01/15 14:12:03 can't accept: listner timed out' after which the nothing further happens in the poll_state_loop. Either it's crashed or stuck Running a ps aux inside the container gives:
So there is a stuck tesla-control process PID 857. When I issue kill -9 857, it kills the stuck process, and the poll_state_loop continues from where it left off. Maybe it is possible for the code to detect this and kill the stuck process. Not sure why there are some many {run.sh} /bin/ash -e /app/run.sh processes All is not lost. Not yet |
Ah, I initially replied here #141 Hi, great job! Bogdan |
Hi, I'm copying my response in this other issue that is the same: tesla-local-control/tesla-local-control-addon#125
The bluetooth receiver crashes with this addon and it reloads on a different hci number but the addon does not adapt to available devices it always expects the receiver on the hci number it found on start. |
@BogdanDIA I agree, I think the passive method of determining presence is the way to go, as it is not likely to overload the bluetooth. I think body-controller-state has its place in confirming whether the car is awake (and therefore present) before sending commands. I believe many people have automations sending commands when the car is away, which eventually crashes the bluetooth. I will therefore revert to checking body-controller-state for the car being awake only when it it time to poll the car, which will drastically reduce the number of calls to tesla-control, and improve robustess. We'll use the passive method for presence detection. I will progress the investigation in this Issue to conclusion, as I have learned something which I believe will allow recovery after a tesla-control call has 'stuck', see next comment (when I've written it!) @chokethenet I think best to wait for the next update when I believe the robustness will improve considerably. In the meantime if you are sending commands with your automations when the car is away, you could improve robustness by not doing so Thanks both for your comments |
I now know that the tesla-control process gets stuck when the bluetooth is getting overloaded, see my earlier post. I suspect that another call whilst the stuck process is still alive causes the hci to jump. So today I used the timeout command to see if I can automatically terminate the stuck process. I modded the line in read-state.sh which calls tesla-control to this:
The timeout command runs the tesla-control command, but forcibly terminates it after 20 secs if it is still running. With the car away all morning, then returning, here are the relevent parts of the logs:
It works and the system recovered not causing the bluetooth to 'jump'. Even though it works, as per my earlier comment I'm going to change presence detection to use the existing passive process. This will dramatically reduce the load on the bluetooth. I will however use body-controller-state to check the car is awake before sending commands. I will also use the timeout command to lauch tesla-control whenever it is called. I believe doing these things will fix most of the issues people are having with bluetooth locking up / jumping etc |
Hi @iainbullock , checking body-controller should be done only when the car is available. In my implementation, I check car's presence with bluetoothctl (I reset the controller with "hciconfig hciX reset" always before checking the presence) and after that I check body-controllers. If car is asleep, wait 3min and execute again in a loop. But there were two things that made my implementation bullet proof:
For no2 I used timeout command, maybe there is a better way but it woks very well with no locks. Check one of the files, e.g.: https://github.com/BogdanDIA/tesla-ble/blob/ha_addon/charging_get_bcontroller.sh |
I like the idea of using the wait command to wait for any sub processes to finish. Do you find you can go straight into sending the next command if you do this, i.e. no need for a sleep command first? |
I did run a loop script for more than 4 hours setting the current between 1 and 2 Amps continuously. |
I've just tested it and I can send commands one after another with no time delay in between. No issues. Thanks a lot for the idea I think this will improve the robustness of the project |
I have implemented these changes into v0.4.3b-dev which is on DockerHub. Main changes are robustness improvements, see the CHANGELOG. |
This might be a problem using body-controller-state for presence.
I have driven my car away from home for the first time today since I installed v0.4.1b-dev several days ago. When I returned presence is no longer working (neither the original presence detection method nor the new one based on body-controller-state - Presence BC). Looking at the logs Presence BC stopped reporting approx 1 hour 50 mins after I left
When I returned I got a shell inside the container and issued the following command (having set $VIN):
It timed out and resulted in this response:
Looks like the bluetooth adapter at hci0 has 'got stuck'
No commands other than the regular body-controller-state commands were sent at this time
The only way out of it is to reboot the host
Things I'm going to try in order:
The text was updated successfully, but these errors were encountered: