agittins / agittins/bermuda

Exactly every six minutes: "Unexpected error fetching bermuda data" - "IndexError: list index out of range"

未关闭
#672 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
2k
派生
70
PR 合并指标
30 天内没有已合并 PR

描述

Hi there and thanks a lot for all the work that went into creating and improving this integration!

[For about 5 years I used a basic BT presence detection that I wrote myself in C using the BT Arduino IDE & libraries for ESP32 - it worked (and it still works) fine but it has a limitation (by design): since the BT and Wi-Fi share the antenna on the ESP32, the ESP32s connect and disconnect to/from the Wi-Fi every second, to scan for BT devices. Once a known BT MAC is "heard", it is reported via MQTT together with its RSSI, and a Node-Red flow decides in which room the device likely is, and updates the HA entities accordingly. Basic, but it works without headaches - in the five years that I used it I only twice had to update it, when I changed my tracked BT device.]

Anyway, I wanted to see if I could "migrate" my automations to Bermuda, so now I'm running them side by side - i.e. wherever I already had an ESP32 BT scanner of my own I also installed an ESP32 running ESPHome with the BT proxy configured and reporting to HA/Bermuda.

I used it like this without issues for a couple of months and recently I noticed that every day or so it "glitches" for a few seconds exactly every six minutes.
It reports my tracked device at home for six minutes, then not at home for a few seconds and once it starts this sequence repeats until I restart HA; then the longer duration cycle also repeats (i.e. every day or so the issue appears again).

I just tried to download the diagnostics but it completely froze my HA instance for a few minutes, then it (HA) restarted by itself with no diagnostics file being produced, so I guess that the info for whatever caused the issue is now gone. Before the restart Bermuda was reporting "46 active out of 3139 bluetooth devices" and "4 active out of 4 bluetooth scanner devices". After the restart it's now reporting "49 active out of 79 bluetooth devices" and "4 active out of 4 bluetooth scanner devices" (all 4 of them well under a second). The 4 BT proxies in my setup are 3 ESP32 D1-minis and the built-in BT interface/module/card/whatever in the Raspberry Pi 4.

Every six minutes I can see this in the HA log file:

```
2025-09-28 16:37:40.727 ERROR (MainThread) [custom_components.bermuda]
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 392, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/bermuda/coordinator.py", line 620, in _async_update_data
self._async_update_data_internal()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/config/custom_components/bermuda/coordinator.py", line 702, in _async_update_data_internal
self.prune_devices()
~~~~~~~~~~~~~~~~~~^^
File "/config/custom_components/bermuda/coordinator.py", line 879, in prune_devices
nowstamp - sorted_addresses[prune_quota_shortfall - 1][0],
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: list index out of range
```

I saw a few other issues about very similar log entries however they are all closed now. (there was also a small difference in the line number on the line `File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 392, in _async_refresh`)

I wondered if some sort of timeout due to system load could be the cause of this issue (for example, the ZHA integration seems to be quite sensitive to system load) and there seem to be some minor load peaks (see the attached screenshot) but I don't believe they would cause this as they are, well, minor, and they also happen even when Bermuda is running just fine.

Any ideas what I could check/do to identify/fix the cause of the issue?

Many thanks!
Image

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。