Avoid using zigbee macs as network macs in hue#175083
Conversation
|
Hey there @marcelveldt, 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 PR fixes a bug in the Philips Hue integration where Zigbee MAC addresses of Hue devices were stored in the device registry as CONNECTION_NETWORK_MAC connections instead of CONNECTION_ZIGBEE. It corrects new device creation and adds a config-entry migration (minor version bump 1 → 2) to fix already-registered devices on existing v2 bridges.
Changes:
- In
v2/device.py, usedr.CONNECTION_ZIGBEE(instead ofCONNECTION_NETWORK_MAC) when registering a device's Zigbee MAC. - Add
async_migrate_entry/_migrate_v2_zigbee_connectionsto rewrite existing devices' connections, bumpMINOR_VERSIONto 2 in the config flow, and gracefully defer migration (retry next start) when the bridge is unavailable. - Add tests for the new device connection, the migration of existing entries, and the v1 skip path; mark existing/mock config entries as
minor_version=2so they bypass the new migration.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| homeassistant/components/hue/v2/device.py | Register Zigbee MAC under CONNECTION_ZIGBEE instead of CONNECTION_NETWORK_MAC. |
| homeassistant/components/hue/init.py | Add async_migrate_entry and helper to migrate existing v2 device connections; defer on bridge errors. |
| homeassistant/components/hue/config_flow.py | Bump MINOR_VERSION to 2 to trigger the migration. |
| tests/components/hue/test_init.py | Add test that new devices get a Zigbee connection; set minor_version=2 on existing entries. |
| tests/components/hue/test_migration.py | Add tests for v2 connection migration and v1 skip behavior. |
| tests/components/hue/conftest.py | Default mock config entries to minor_version=2 to skip the new migration. |
| except AiohueException, aiohttp.ClientError, TimeoutError: | ||
| # bridge unavailable, retry the migration on the next start | ||
| return True |
| await _migrate_v2_zigbee_connections(hass, entry) | ||
| except AiohueException, aiohttp.ClientError, TimeoutError: | ||
| # bridge unavailable, retry the migration on the next start | ||
| return True |
There was a problem hiding this comment.
How many times we allow the migrations retry? Also, maybe the users should be getting some information in the logging (e.g. maybe they can fix stuff on their end if they're aware of it).
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Proposed change
Avoid using zigbee macs as network macs in hue
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: