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

Bluetooth connection failures #90

Open
Fernandroide opened this issue Jan 12, 2025 · 19 comments
Open

Bluetooth connection failures #90

Fernandroide opened this issue Jan 12, 2025 · 19 comments

Comments

@Fernandroide
Copy link

I have a problem with the integration. Occasionally, the Bluetooth connection is lost, it is reset and then again...
logs_victron-ble_logs(1).txt
logs_victron-ble_logs(3).txt

@Fabian-Schmidt
Copy link
Owner

Hi, the log highlights an issue with your WiFi connection to read logs from your home assistant to the esp. I don't see any Bluetooth or victron messages.

@Fernandroide
Copy link
Author

However, in ESPhome you can see that the devices are online.
I don't have much knowledge of home assistant, but I can't find any reason for this failure. The router is a few meters from the esp32.
imagen

@Fernandroide
Copy link
Author

If the problem is with the Wi-Fi connection, I will try with a fixed IP on the ESP-32

@axwell
Copy link

axwell commented Jan 14, 2025

I have a similar issue, ble is loosing connectivity from time to time, esp32 module is 10 cm away from the victron mppt, wifi is steady, i can fix it only a reboot of the ble module... :(

@Fabian-Schmidt
Copy link
Owner

There is no active connectivity between the ESP and the Victron device. The Victron device is just broadcasting Bluetooth advertising package which the ESP reads. The ESP then encrypts the package, translates it and sends it to Home Assistant.

How does this 'loosing connectivity' manifest?
Do you no longer get updates in Home Assistant?
Or is just the issue that the ESPHome log cannot be received?

@axwell
Copy link

axwell commented Jan 15, 2025

@Fabian-Schmidt i don 't get updates in home assistant from victron specifically and in on ESP logs about the victron ble broadcasts, everything else on ESP works fine, i can connect to it, read other stuff from logs, control it..., victron is still broadcasting because victron app works just fine.

Before i thought distance is too big 2 meters away, so i moved the esp32 next to the victron mppt.

This issue occurs every couple of days but is not a fixed interval most of the time.
Also i tested this also with a victron smart battery sense, that device had the same issue but less frequently.

Victron is up to date running latest firmware.

@Fabian-Schmidt
Copy link
Owner

What are you doing to fix the issue? Power cycle the esp device?

Just FYI the victron will stop sending Bluetooth advertising packages when you use the victron app and connect to the device - select the device not just see it in the overview page.

@axwell
Copy link

axwell commented Jan 15, 2025

Yes, i just power cycle from home assistant.
Yes i'm aware that using the app stops advertising packages, but it's not the case, i only checked the app after advertising packages stops to be received just to check if in the app it works.

@Fabian-Schmidt
Copy link
Owner

Can you please share the ESPHome log when the issue occurs and it no longer transmit sensors to home assistant?

@Fernandroide
Copy link
Author

Fernandroide commented Jan 24, 2025

in my case I have been working for days without problems. Entities are available permanently. I thought my problems could be caused by the ESP feeder... but nothing to modify seems that now everything is fine... I do not understand what the problem was.

@Fernandroide
Copy link
Author

Fernandroide commented Jan 24, 2025

in my case I have been working for days without problems. Entities are available permanently. I thought my problems could be caused by the power supply of the ESP feeder... but nothing to modify seems that now everything is fine... I do not understand what the problem was.

@Anto79-ops
Copy link

Anto79-ops commented Feb 5, 2025

hello, im also experieincing the same. My ESP32 devices is about 10 ft LOS from the SmartShunt and it still seems to loose BT connections. What ends up happening is the devices will just stop reporting, and only show the last number. I suspected it was WiFi, but when its in this "stalled state" the wifi to the devices works well and I can connecto to it via ESPHome and see the logs.

You can see here, the flat-lines/part is when it stops reporting.

Image

If you leave it alone, it radonomly connects and disconnects. A reboot of the ESP32 also fixes this.

I thought perhaps of adding an automation that if the device does not report for more than 3 minutes, to reboot it. I just might do that.

thanks

@phurth
Copy link

phurth commented Feb 5, 2025

I have two Smart Shunts, both being read by ESP32s with this integration. The BT range on the Smart Shunt is extremely short. Unless I have the ESP (or even my phone if using the Victron app) more than about 5-6 feet away, the connection becomes very unreliable.

@Fabian-Schmidt
Copy link
Owner

hello, im also experieincing the same. My ESP32 devices is about 10 ft LOS from the SmartShunt and it still seems to loose BT connections. What ends up happening is the devices will just stop reporting, and only show the last number. I suspected it was WiFi, but when its in this "stalled state" the wifi to the devices works well and I can connecto to it via ESPHome and see the logs.

You can see here, the flat-lines/part is when it stops reporting.

Image

If you leave it alone, it radonomly connects and disconnects. A reboot of the ESP32 also fixes this.

I thought perhaps of adding an automation that if the device does not report for more than 3 minutes, to reboot it. I just might do that.

thanks

It is hard to identify the root cause of the problem without a log.
Can you please enable logging on the ESPHome device and share a log while the device does not submit values.

@Anto79-ops
Copy link

Hi @Fabian-Schmidt thanks for your reply. I'd be happy to share more information. Could you please tell me how to enable logging to a specific ESPHome device? for example, now its in that non-reporting state:

Image

But, when I go to ESPHome dashboard and selected logs from the the device via wifi, it connects and gives me these logs:

logs_victron-ble_logs.txt

I presume I have to get the logs before the issue happens. Could you tell me how?

thanks!

@Anto79-ops
Copy link

for 2025.3.0, there is a new feature that you can enable specific ESPHome device logs.

Image

I've enabled it for the Victron BLE device, perhaps I can catch why the device disconnect via BLE but not via Wifi. Keep you posted.

@Anto79-ops
Copy link

ok @Fabian-Schmidt , I have some updates here. Here's an overnight trace of the device

Image

you can see places where the device goes flatline, this is where it stops reporting, and then reconnects at some point later.

just to confirm there is no wifi issue, you can see here, the history of the restart button, only goes unaviable briefly when the device restarts (I think):

Image

So what are the logs for the relevent times of 8:55pm, 2:03 am, 5:02 and 6:42 am, here's what I see:

2025-02-28 02:02:33.121 WARNING (MainThread) [aioesphomeapi.connection] victron-ble @ 192.168.1.76: Connection error occurred: [Errno 104] Connection reset by peer
2025-02-28 06:42:13.641 ERROR (MainThread) [homeassistant.components.esphome.manager] Victron BLE: [E][esp32_ble_tracker:296]: ESP-IDF BLE scan never terminated, rebooting to restore BLE stack...
2025-02-28 06:42:19.690 WARNING (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for victron-ble @ 192.168.1.76: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.1.76', port=6053))]: [Errno 111] Connect call failed ('192.168.1.76', 6053) (SocketAPIError)

im not sure if this helpful, I could incresase the log level detail as its not default.

@Anto79-ops
Copy link

another update, according to bdraco, there might be a possible fix coming for this. May wish to track these issues:

esphome/issues#5119
esphome/esphome#8328

@Anto79-ops
Copy link

Since the ESPHome update, I've noticed marked improvement of the BT connection. There's only a couple of small gaps in the data generation as shown here:

Image

For some reason, I had turned off device logging so im not sure what caused those. I'll try the logging again.

thanks

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

No branches or pull requests

5 participants