Skip to content

Discover SONOFF water valve as MQTT valve - #32367

Open
MaxRink wants to merge 1 commit into
Koenkk:devfrom
MaxRink:ha-discovery-valve-switch
Open

Discover SONOFF water valve as MQTT valve#32367
MaxRink wants to merge 1 commit into
Koenkk:devfrom
MaxRink:ha-discovery-valve-switch

Conversation

@MaxRink

@MaxRink MaxRink commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Discover switch exposes as Home Assistant MQTT valve entities when ZHC expose metadata declares homeassistant: {type: "valve"}.

The object ID remains the existing switch-shaped value (switch or switch_<endpoint>), so this PR does not add an avoidable entity rename on top of the Home Assistant component/domain migration.

Why

SONOFF water valves are exposed by ZHC as on/off switch-like Zigbee devices, but they are semantically valves in Home Assistant. ZHC now carries this intent on the expose itself via withHomeAssistant, so Zigbee2MQTT can translate that generic expose metadata without hardcoding a device model.

Review note

Koenkk flagged that changing the Home Assistant component and the object ID together would be breaking for users. This PR stays narrow and keeps the object ID stable, so only the HA component mapping changes here.

Validation

Local validation in /private/tmp/z2m-valve-discovery:

  • node --run check
  • node --run test -- test/extensions/homeassistant.test.ts -t "MQTT valve"
  • node --run build
  • git diff --check origin/dev...HEAD

Paired work

  • ZHC already marks the SONOFF valve on/off exposes with homeassistant: {type: "valve"}.

@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
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