Skip to content

Fix HA startup timeout and BLEDevice.rssi AttributeError (0.3.2)#10

Merged
kyleberry merged 1 commit into
mainfrom
fix/startup-and-rssi
Mar 22, 2026
Merged

Fix HA startup timeout and BLEDevice.rssi AttributeError (0.3.2)#10
kyleberry merged 1 commit into
mainfrom
fix/startup-and-rssi

Conversation

@kyleberry

Copy link
Copy Markdown
Owner

Bug fixes found during live testing:

  1. Startup timeout (stage 2 bootstrap cancelled) async_config_entry_first_refresh() blocked HA's boot sequence. With multiple sensors at 10-45s per GATT connection, the cumulative time exceeded HA's stage 2 timeout. Replaced with entry.async_create_background_task() so setup returns immediately and the initial audit runs after HA finishes booting.

  2. AttributeError: 'BLEDevice' object has no attribute 'rssi' BLEDevice.rssi was removed in newer bleak/habluetooth. Switched to bluetooth.async_last_service_info(hass, mac) which returns the last advertisement data including RSSI and source — the correct HA API. Falls back to None/ble_device.details if service info is unavailable.

Tests:
Added test_initial_audit_scheduled_as_background_task to verify setup schedules a background task rather than blocking. Added test_source_and_rssi_fallback_when_service_info_none to cover the service_info=None fallback path. Updated test_model_detection_logic to assert RSSI comes from service_info rather than ble_device.

Bug fixes found during live testing:

1. Startup timeout (stage 2 bootstrap cancelled)
   async_config_entry_first_refresh() blocked HA's boot sequence.
   With multiple sensors at 10-45s per GATT connection, the cumulative
   time exceeded HA's stage 2 timeout. Replaced with
   entry.async_create_background_task() so setup returns immediately
   and the initial audit runs after HA finishes booting.

2. AttributeError: 'BLEDevice' object has no attribute 'rssi'
   BLEDevice.rssi was removed in newer bleak/habluetooth. Switched to
   bluetooth.async_last_service_info(hass, mac) which returns the last
   advertisement data including RSSI and source — the correct HA API.
   Falls back to None/ble_device.details if service info is unavailable.

Tests:
   Added test_initial_audit_scheduled_as_background_task to verify
   setup schedules a background task rather than blocking.
   Added test_source_and_rssi_fallback_when_service_info_none to cover
   the service_info=None fallback path.
   Updated test_model_detection_logic to assert RSSI comes from
   service_info rather than ble_device.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kyleberry
kyleberry merged commit 5a38bfb into main Mar 22, 2026
2 checks passed
@kyleberry
kyleberry deleted the fix/startup-and-rssi branch March 22, 2026 21:34
kyleberry pushed a commit that referenced this pull request Jul 17, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/checkout](https://github.com/actions/checkout) | action | major | `v6` → `v7` |

---

### Release Notes

<details>
<summary>actions/checkout (actions/checkout)</summary>

### [`v7.0.0`](https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v700)

[Compare Source](actions/checkout@v7.0.0...v7.0.0)

- Block checking out fork PR for pull\_request\_target and workflow\_run by [@&#8203;aiqiaoy](https://github.com/aiqiaoy) in [#&#8203;2454](actions/checkout#2454)
- Bump actions/publish-immutable-action from 0.0.3 to 0.0.4 in the minor-actions-dependencies group across 1 directory by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2458](actions/checkout#2458)
- Bump flatted from 3.3.1 to 3.4.2 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2460](actions/checkout#2460)
- Bump js-yaml from 4.1.0 to 4.2.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2461](actions/checkout#2461)
- Bump [@&#8203;actions/core](https://github.com/actions/core) and [@&#8203;actions/tool-cache](https://github.com/actions/tool-cache) and Remove uuid by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2459](actions/checkout#2459)
- upgrade module to esm and update dependencies by [@&#8203;aiqiaoy](https://github.com/aiqiaoy) in [#&#8203;2463](actions/checkout#2463)
- Bump the minor-npm-dependencies group across 1 directory with 3 updates by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2462](actions/checkout#2462)

### [`v7`](https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v701)

[Compare Source](actions/checkout@v6.0.3...v7.0.0)

- Bump github/codeql-action from 3 to 4 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2475](actions/checkout#2475)
- Bump actions/setup-node from 4 to 6 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2477](actions/checkout#2477)
- Bump docker/build-push-action from 6.5.0 to 7.2.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2478](actions/checkout#2478)
- Bump docker/login-action from 3.3.0 to 4.2.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2479](actions/checkout#2479)
- Bump actions/checkout from 6 to 7 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2488](actions/checkout#2488)
- Bump actions/upload-artifact from 4 to 7 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2476](actions/checkout#2476)
- eslint 9 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2474](actions/checkout#2474)
- Bump the minor-actions-dependencies group with 2 updates by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;2499](actions/checkout#2499)
- skip running unsafe pr check if input is default by [@&#8203;aiqiaoy](https://github.com/aiqiaoy) in [#&#8203;2518](actions/checkout#2518)
- trim only ascii whitespace for branch by [@&#8203;aiqiaoy](https://github.com/aiqiaoy) in [#&#8203;2521](actions/checkout#2521)
- escape values passed to --unset by [@&#8203;aiqiaoy](https://github.com/aiqiaoy) in [#&#8203;2530](actions/checkout#2530)

</details>

---

### Configuration

📅 **Schedule**: (in timezone America/Chicago)

- Branch creation
  - "on monday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNDkuNSIsInVwZGF0ZWRJblZlciI6IjQzLjI0OS41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.berry.house/kyleberry/sensorpush_local/pulls/10
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

Successfully merging this pull request may close these issues.

1 participant