Skip to content

test(ha): verify generic valve discovery and migration - #32367

Open
MaxRink wants to merge 2 commits into
Koenkk:devfrom
MaxRink:ha-discovery-valve-switch
Open

MaxRink wants to merge 2 commits into
Koenkk:devfrom
MaxRink:ha-discovery-valve-switch

Conversation

@MaxRink

@MaxRink MaxRink commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Verify that switch exposes can already be discovered as Home Assistant MQTT valves through the existing generic homeassistant.type metadata and ZHC overrideHaDiscoveryPayload callback. The final change adds integration tests only: the valve-specific Zigbee2MQTT discovery branch has been removed.

The tests cover ordinary and endpoint-scoped valves, ON/OFF open/close payloads and states, endpoint command topics, stable discovery object IDs and unique IDs, and removal of the previous retained switch discovery.

Migration

Changing the Home Assistant component from switch to valve creates a different entity-domain identity even with the same unique_id. Home Assistant's registry keys entries by (domain, platform, unique_id): https://github.com/home-assistant/core/blob/dev/homeassistant/helpers/entity_registry.py

The tests verify removal of the old retained switch discovery; they do not claim to preserve the old Home Assistant entity registry entry. Existing automations and dashboards referencing the switch entity need migration. No live Home Assistant instance was used.

Paired converter change

Koenkk/zigbee-herdsman-converters#13232 enables the existing metadata and callback for SONOFF SWV-ZFE/ZFU, SWV-ZF2 and SWV-ZNE/ZNU. This test-only PR does not activate device behavior by itself.

Validation

  • Node 24 build and Biome checks passed.
  • All 93 Home Assistant tests passed, including both new migration/discovery cases.
  • Full suite with coverage passed outside the sandbox: 826 tests across 25 files; 100% statements, branches, functions and lines (Node 24, two workers, 60-second test timeout).

@MaxRink
MaxRink force-pushed the ha-discovery-valve-switch branch from 1d7a9d2 to 19a2ac1 Compare June 22, 2026 10:55
@MaxRink
MaxRink changed the base branch from master to dev June 22, 2026 10:55
@MaxRink
MaxRink force-pushed the ha-discovery-valve-switch branch 3 times, most recently from b4e01f6 to 6e1e2e6 Compare June 22, 2026 11:30
@Koenkk

Koenkk commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Given that the object_id changes, I believe this is a breaking change?

@MaxRink
MaxRink force-pushed the ha-discovery-valve-switch branch from 6e1e2e6 to 1f86eb0 Compare June 22, 2026 19:44
@MaxRink

MaxRink commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

Yes, changing the Home Assistant discovery component from switch to valve is still a migration to call out.

I adjusted the implementation so the old object ID shape is preserved (switch / switch_<endpoint>). That avoids an extra entity rename on top of the intended component/domain change.

@Koenkk

Koenkk commented Jun 23, 2026

Copy link
Copy Markdown
Owner
  • Can you verify that with this change no new entity is created?
  • I would prefer to introduce a more generic mechanism to change HA expose properties (e.g. directly on the expose itself in zhc instead of on meta)

@MaxRink
MaxRink force-pushed the ha-discovery-valve-switch branch from ba3bc8a to bdf543a Compare June 23, 2026 18:44
@Koenkk

Koenkk commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Im wondering if we maybe can just do this through the override ha discovery payload which already exists in zhc?

@MaxRink
MaxRink marked this pull request as draft June 25, 2026 17:05
@MaxRink
MaxRink force-pushed the ha-discovery-valve-switch branch from bdf543a to c1e78d9 Compare June 25, 2026 17:52
@MaxRink
MaxRink marked this pull request as ready for review July 4, 2026 19:46
@MaxRink
MaxRink force-pushed the ha-discovery-valve-switch branch from c1e78d9 to 7782333 Compare July 31, 2026 12:11
@MaxRink
MaxRink force-pushed the ha-discovery-valve-switch branch from 7782333 to 895091e Compare August 14, 2026 17:35
@MaxRink
MaxRink force-pushed the ha-discovery-valve-switch branch from 895091e to 6c2452c Compare August 28, 2026 01:28
Signed-off-by: Maximilian Rink <maximilian.rink@telekom.de>
@MaxRink MaxRink changed the title Discover SONOFF water valve as MQTT valve test(ha): verify generic valve discovery and migration Sep 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants