-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Add Bluetooth WiFi provisioning for Shelly #155822
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
base: dev
Are you sure you want to change the base?
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 adds Bluetooth Low Energy (BLE) provisioning support to the Shelly integration, allowing users to configure WiFi credentials for Shelly devices discovered via Bluetooth. The implementation includes a complete provisioning flow that scans WiFi networks via BLE, provisions credentials, and waits for the device to appear on the network via zeroconf discovery.
Key Changes
- Adds BLE discovery source that provisions WiFi credentials to unpaired Shelly devices
- Implements WiFi network scanning and credential provisioning via BLE with progress tracking
- Coordinates between BLE provisioning and zeroconf discovery for seamless device handoff
- Adds comprehensive test coverage for all provisioning flows and edge cases
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
tests/components/shelly/test_config_flow.py |
Adds ~1100 lines of test coverage for BLE discovery and provisioning flows including success, failure, and edge cases |
homeassistant/components/shelly/config_flow.py |
Implements BLE discovery handlers, WiFi scanning, and provisioning logic with zeroconf coordination |
homeassistant/components/shelly/ble_provisioning.py |
New module for tracking provisioning state and registering zeroconf discoveries |
homeassistant/components/shelly/const.py |
Adds BLE provisioning constants including timeout and SSID config key |
homeassistant/components/shelly/strings.json |
Adds user-facing strings for BLE provisioning flow steps and error messages |
homeassistant/components/shelly/manifest.json |
Declares Bluetooth matcher for Shelly devices |
homeassistant/generated/bluetooth.py |
Registers Shelly domain for Bluetooth discovery matching |
Comments suppressed due to low confidence (1)
homeassistant/components/shelly/config_flow.py:1
- Multiple assertions are used throughout the provisioning flow for runtime checks. These should be replaced with proper error handling that will work correctly even when Python is run with optimizations enabled. For instance, at line 555-556, if
state.hostorstate.portare None after discovering the device, this indicates a logical error that should be handled gracefully rather than silently failing in optimized mode.
"""Config flow for Shelly integration."""
Proposed change
Adds Bluetooth Low Energy WiFi provisioning support for Shelly Gen2+ devices.
This lets users set up Shelly devices that aren't yet connected to WiFi by provisioning network credentials directly via Bluetooth. The flow scans for available networks, lets the user select one and enter the password, then waits for the device to connect and complete setup automatically.
The integration handles edge cases like provisioning failures, network timeouts, and seamlessly hands off to zeroconf discovery once the device connects to WiFi.
Type of change
Additional information
Checklist
ruff format homeassistant tests)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.