Skip to content

Conversation

@bdraco
Copy link
Member

@bdraco bdraco commented Nov 5, 2025

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

  • New feature (which adds functionality to an existing integration)

Additional information

  • Requires aioshelly library updates with BLE provisioning support
  • Works with Shelly Gen2+ devices that have RPC-over-BLE enabled
  • 100% test coverage on the config flow

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.

@home-assistant
Copy link

home-assistant bot commented Nov 5, 2025

Hey there @bieniu, @thecode, @chemelli74, mind taking a look at this pull request as it has been labeled with an integration (shelly) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of shelly can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign shelly Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@bdraco bdraco marked this pull request as ready for review November 5, 2025 01:17
@bdraco bdraco requested a review from bieniu as a code owner November 5, 2025 01:17
Copilot AI review requested due to automatic review settings November 5, 2025 01:17
Copy link
Contributor

Copilot AI left a 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.host or state.port are 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."""

@thecode thecode added the noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear) label Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

by-code-owner cla-signed has-tests integration: shelly new-feature noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear) Quality Scale: silver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants