Fix MAC address mix-ups between WLED devices#155491
Conversation
|
Hey there @frenck, 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.
Pull Request Overview
This pull request adds reconfiguration support for the WLED integration, allowing users to change the host address without removing and re-adding the device. Additionally, it implements MAC address verification to ensure devices aren't swapped during reconfiguration or polling.
Key changes:
- Added reconfiguration flow to update host addresses
- Implemented MAC address mismatch detection in the coordinator
- Added test coverage for the new reconfiguration scenarios
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/wled/config_flow.py |
Added async_step_reconfigure method and unique ID validation during reconfiguration |
homeassistant/components/wled/coordinator.py |
Introduced WLEDConfigEntry type alias and MAC address mismatch detection in data updates |
homeassistant/components/wled/__init__.py |
Updated to import and use WLEDConfigEntry from coordinator module |
homeassistant/components/wled/strings.json |
Added user-facing messages for reconfiguration success and unique ID mismatch |
tests/components/wled/test_config_flow.py |
Added tests for successful reconfiguration and unique ID mismatch scenarios |
tests/components/wled/test_sensor.py |
Added test to verify entity unavailability when MAC address mismatches |
|
|
||
|
|
||
| @pytest.mark.usefixtures("mock_setup_entry", "mock_wled") | ||
| async def test_full_reconfigure_flow_unique_id_mismatch( |
There was a problem hiding this comment.
In circumstances it can fail at reconfigure right? Since it uses the user_step, but that has a try-except that can fail. Normally it's good practice to write a test that initially fails and then demonstrates the flow can recover and successfully reconfigure. That would be a good additional test. :)
There was a problem hiding this comment.
I added a new test case: test_full_reconfigure_flow_connection_error_and_success . I think this is what you need.
e5a82b0 to
79654b2
Compare
🎉 |
Co-authored-by: mik-laj <12058428+mik-laj@users.noreply.github.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Breaking change
Proposed change
Fix MAC address mix-ups between WLED devices
This PR fixes an issue where Home Assistant could accidentally associate a WLED config entry with the wrong physical device when host/IP information changes (e.g. after DHCP reassignment or moving controllers between locations).
WLED does not guarantee stable hostnames, and the integration previously did not validate the MAC address returned at runtime, so a stale IP or reused hostname could cause HA to load data from an unintended device. This manifested as:
Here is discussion about this problem: https://discord.com/channels/330944238910963714/1431013499466809364/1431013499466809364
Runtime MAC-address validation
The coordinator now validates that the device we connect to at runtime matches the MAC stored in the config entry.
If the MAC does not match:
This ensures that each WLED entry always represents exactly one physical controller.
Reconfigure flow
To give users a way to fix the mismatch error, this PR adds a reconfigure flow for WLED.
This allows the user to:
If the MAC matches, the entry is updated and the flow aborts with
reconfigure_successful.If the MAC does not match, the flow aborts with
unique_id_mismatchto prevent linking to the wrong device.Type of change
Additional information
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: