vNext: group VRF sub-units under a gateway device - #529
Merged
Merged
Conversation
Every local VRF gateway MAC with at least one sub-unit now gets a controller device without entities, identifier controller_<mac>. The sub-units point to it with via_device_id, so the device page shows the gateway with its indoor units under Connected devices. - The link is set from setup code with async_update_device, not through DeviceInfo: HA 2026.3 only has via_device, 2026.9 only via_device_id. - Setup reconciles instead of recreating: wanted controllers keep their device id, name and area; controllers without sub-units are removed. - Grouping uses the saved mac_controller_local, not the runtime controller MAC, which follows the bound transport. - Deleting a controller raises remove_vrf_controller. Deleting its last sub-unit removes the controller at once. - Controller diagnostics hold the diagnostics of each sub-unit. - Cloud-only VRF gets no controller yet. The raw cloud device list is logged at debug level with the keys redacted, so users can share pmac. The old raw log of GetDevsInRoomsOfHomeV2 is removed: it held every device key in clear text. Tested in the dev instance against two fake gateways (2 units and 1 unit): links set, delete of the controller refused, controller gone with its last unit, device id kept over a reload. Offline harness 17/17, pytest 249 passed.
Review points from Pedro: - The gateway device has the gateway MAC as connection. Discovery never returns the gateway itself as a device, so nothing else has that MAC. - Its sw_version and hw_version come from the first bound sub-unit, because the firmware belongs to the WiFi module of the gateway. - One DeviceInfo for all units: the VRF branch in entity.py only left out hw_version and model_id, and the link is set from setup now.
Owner
Author
|
Review points from Pedro are in (bcd3c82):
Testing after these changes:
The PR description is updated to match. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groups the indoor units of a local VRF gateway under a gateway device, as Pedro proposed on Discord.
1. Gateway device with Connected devices
Change. Every local gateway MAC (
connection.local.mac_controller_local) with at least one sub-unit gets a controller device: identifier(gree_custom, "controller_<mac>"), modelVRF gateway, translated nameVRF gateway <last 5 of mac>, no entities. Each sub-unit getsvia_device_idto it, so the gateway page shows the units under Connected devices. A gateway with one sub-unit gets one too.Design points.
DeviceInfodoes not create a missing via device: HA logsnon existing via_deviceand drops the link. So the controllers are created inasync_setup_entrybefore the platforms load.async_update_device(via_device_id=...)after the platforms load, not throughDeviceInfo. HA 2026.3 (our minimum inhacs.json) only hasvia_deviceinDeviceInfo, and 2026.9 only hasvia_device_id.async_update_devicehasvia_device_idin both.mac_controller_local, notdevice.mac_address_controller. The runtime value follows the bound transport (for MQTT it is the first 12 chars of the cloud MAC), so the parent could flip after a fallback.connections. Discovery never returns the gateway itself as a device, so no other device of this integration has that MAC.sw_versionandhw_versioncome from the first bound sub-unit, because the firmware belongs to the WiFi module of the gateway. Without a bound sub-unit the registry keeps the last known values. This assumes all sub-units of a gateway report the same firmware; a full status of a real sub-unit would confirm it.DeviceInfofor every unit. The VRF branch inentity.pyonly left outhw_versionandmodel_id, and the link no longer needs it. Sub-units now show both.2. Delete and diagnostics
HomeAssistantErrorwithremove_vrf_controller: "This is a VRF controller. Delete its sub-units first, and the controller is deleted automatically." ReturningFalsewould only show HA's generic "rejected by integration".controller_macandsub_units: the diagnostics of each sub-unit,""for one that is not bound.3. Cloud VRF: data first
Cloud-only VRF units get no controller yet, because we do not know what
pmacholds.get_all_devices()now logsRaw cloud device listat debug level, before the duplicate filter, withkeyredacted.docs/troubleshooting.mdasks cloud VRF users to share that line.Security fix in the same file.
get_devices()logged the decryptedGetDevsInRoomsOfHomeV2reply with_LOGGER.debug(data), which holds every device key in clear text. That line is removed, because the new troubleshooting text asks users to post exactly this debug log.Testing
Dev instance (HA 2026.9) with two fake gateways from
tests/fakes/vrf.pyinside the container: gateway A with 2 units, gateway B with 1 unit, added as a local YAML entry.VRF-gateway d5ba3,VRF-gateway d7c11, Dutch instance), all 3 sub-units havevia_device_idto their gateway.connections94:24:b8:fd:5b:a3and the firmware of its sub-unit; sub-units showhw_version.Offline harness (real helpers and diagnostics against a stub registry): 20 passed, 0 failed. Covers stale controller removal, the MAC connection, firmware from the first bound sub-unit, a controller of another entry left alone, no writes on a second setup, cloud-only unit not linked, controller and normal diagnostics.
pytest 249 passed. ruff check and format pass. mypy on the changed files: no new errors (the 5 remaining are old, in
select.py,config_schema.py,services.py).Notes
via_device_idwhile its old gateway still has other units. Rare, left out.