Add network MAC connection to Rain Bird controller#173672
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Hey there @konikvranik, @allenporter, 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
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds a network MAC connection to the Rain Bird controller's device registry entry, allowing Home Assistant to associate the device with its network MAC address for improved device identification and tracking.
Changes:
- Added
CONNECTION_NETWORK_MACto theDeviceInfoin the coordinator so the device registry includes the MAC address as a network connection. - Added a new test (
test_device_registry) to verify the controller device registry entry includes the MAC connection. - Added a snapshot file for the new device registry test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| homeassistant/components/rainbird/coordinator.py | Adds connections field with CONNECTION_NETWORK_MAC to the device info using the existing unique ID (which is a MAC address). |
| tests/components/rainbird/test_init.py | Adds a new test to validate the device registry entry, including the MAC connection. |
| tests/components/rainbird/snapshots/test_init.ambr | Snapshot for the new device registry test. |
allenporter
left a comment
There was a problem hiding this comment.
Looks like a great thing to fix, thank you! Though i have some caveats, and have requested a change below.
| return DeviceInfo( | ||
| name=self.device_name, | ||
| identifiers={(DOMAIN, self._unique_id)}, | ||
| connections={(CONNECTION_NETWORK_MAC, self._unique_id)}, |
There was a problem hiding this comment.
unique id is /currently/ the mac address but in the past was the serial number. Instead can you pull this from entry.data.get(CONF_MAC)? It needs to be done conditionally in case it is not set.
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Proposed change
Register the Rain Bird controller with its network MAC address as a connection so
the MAC is shown on the device page and other integrations can attach to the same
device.
The controller's config entry unique id is already the formatted MAC (derived
from the device's Wi-Fi MAC during setup) and is used as the device identifier,
but the device was registered without any
connections. As a result, HomeAssistant did not display the MAC on the device page, and integrations that key
off the network MAC (for example, the UniFi Network integration) created a
separate device for the same physical unit. Adding the
CONNECTION_NETWORK_MACconnection fixes both.
The connection is added to the controller device only. The per-zone switch
devices remain linked to the controller via
via_device, so no connection tupleis duplicated across devices.
This is the same change applied to Aranet in #173066 and to AirVisual Pro in
#173071.
Please re-classify it as a Bugfix if deemed appropriate (as one could argue a
network device should always carry its network MAC connection).
Tested on real hardware (a Rain Bird ESP-ME3 controller). With the change
applied, the controller's device page shows its MAC address, and the UniFi
Network integration's client device merges onto the same device via the new
connection instead of remaining a separate entry. The change is also covered by
a new device-registry snapshot test that asserts the network MAC connection is
registered on the controller device.
Below, the controller device page before and after the change. Before: no MAC,
Rain Bird only. After: the MAC is shown and the UniFi Network integration has
merged onto the same device.
Before:

After:

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: