-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Keep persistent BLE connection during Shelly WiFi provisioning #158145
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
Conversation
|
Hey there @bieniu, @thecode, @chemelli74, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request maintains a persistent BLE connection during Shelly WiFi provisioning to fix an issue where some Shelly devices (particularly XSM boards) fail to re-establish BLE connections once dropped. Previously, the config flow created a new BLE connection for each operation (WiFi scan and provisioning), which caused certain devices to fail during the second connection attempt.
Key Changes:
- Introduces persistent
RpcDeviceinstance across config flow steps via_ble_rpc_deviceinstance variable - Replaces helper functions (
async_scan_wifi_networks,async_provision_wifi) with direct method calls on the persistent device (wifi_scan(),wifi_setconfig()) - Implements proper cleanup via
async_remove()callback and in provisioning completion paths
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| homeassistant/components/shelly/config_flow.py | Added _ble_rpc_device instance variable and three new methods (_async_ensure_ble_connected, _async_disconnect_ble, _async_get_ip_from_ble) to manage persistent BLE connections; updated WiFi scan and provisioning steps to use persistent connection; added async_remove() callback for cleanup on flow abort |
| tests/components/shelly/test_config_flow.py | Replaced old fixtures (mock_wifi_scan, mock_wifi_provision) with new fixtures (mock_ble_rpc_device, mock_ble_rpc_device_class) that mock the persistent RpcDevice; updated all BLE provisioning tests to use new mocking approach; added new test for cleanup verification; fixed incorrect await on sync async_abort() method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
|
Thanks. Still works fine |
Proposed change
Keep a persistent BLE connection open between Shelly WiFi scan and provisioning steps during BLE-based device setup.
Some Shelly devices (particularly XSM boards) fail to re-establish the BLE connection once dropped, making persistent connections essential for reliable provisioning. Previously, the config flow created a new BLE connection for each operation (WiFi scan and WiFi provisioning), which caused these devices to fail during the second connection attempt.
This change:
RpcDeviceinstance across config flow stepswifi_scan()and extendedwifi_setconfig()methods onRpcDeviceinstead of the helper functions that create their own connectionsType of change
Additional information
Note: This PR requires aioshelly 13.23.0 (or newer) which adds
wifi_scan()and extendswifi_setconfig()onRpcDevice. It should be merged after the aioshelly PR is merged and released.Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: