Skip to content

Add Matter water valve support and example sketch - #182

Open
Ludovic BOUÉ (lboue) wants to merge 3 commits into
SiliconLabsSoftware:mainfrom
lboue:Matter-WaterValve
Open

Add Matter water valve support and example sketch#182
Ludovic BOUÉ (lboue) wants to merge 3 commits into
SiliconLabsSoftware:mainfrom
lboue:Matter-WaterValve

Conversation

@lboue

@lboue Ludovic BOUÉ (lboue) commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Add Matter Water Valve support

Summary

  • Adds a new MatterWaterValve Arduino API on top of the Matter Valve Configuration and Control cluster (device type 0x0042), following the existing Device/MatterEndpoint pattern used by other Matter appliances in this core.
  • Adds the backing DeviceWaterValve class (libraries/Matter/src/devices/DeviceWaterValve.{h,cpp}) implementing CurrentState, TargetState, OpenDuration, DefaultOpenDuration, RemainingDuration, and ValveFault attributes, plus HandleReadEmberAfAttribute/HandleWriteEmberAfAttribute overrides.
  • Adds MatterWaterValve.{h,cpp} with a public API to open the valve indefinitely or for a set duration, close it, and read/write duration and fault state, along with a command handler for the cluster's Open/Close commands.
  • Registers the new device type in MatterEndpoint.h (DEVICE_TYPE_WATER_VALVE) and devices/MatterDevice.h (kDeviceType_WaterValve).
  • Adds the matter_watervalve example sketch demonstrating commissioning, opening the valve with a countdown duration, closing it, and mirroring valve state on the built-in LED.
  • Registers the new example in test/build/test_build.py under testlist_matter so it's built by CI across all Matter-capable boards.
image

@silabs-bozont Tamas Jozsi (silabs-bozont) added the Community contribution PR contents contributed by the community label Jul 6, 2026
@lboue
Ludovic BOUÉ (lboue) marked this pull request as ready for review July 6, 2026 16:11
@silabs-bozont Tamas Jozsi (silabs-bozont) added Under review Request or issue under review Run CI Matter Run Matter specific build tests labels Jul 8, 2026
@github-actions github-actions Bot removed the Run CI Matter Run Matter specific build tests label Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for implementing this - it'll be a great addition to the library. I've tested it with Home Assistant - works as expected. I had a few minor remarks, after fixing them we're good to go.

Comment thread libraries/Matter/examples/matter_water_valve/matter_water_valve.ino
Comment thread libraries/Matter/examples/matter_watervalve/matter_watervalve.ino Outdated
Comment thread libraries/Matter/src/MatterWaterValve.cpp Outdated
Comment thread libraries/Matter/examples/matter_water_valve/matter_water_valve.ino
Comment thread libraries/Matter/src/MatterWaterValve.h Outdated
@lboue

Ludovic BOUÉ (lboue) commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Push fixes into 067c73a

Restricts the public setter to defined fault values instead of an
arbitrary uint16_t, per PR review feedback.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

// Valve Configuration and Control cluster attributes
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(waterValveConfigurationAndControlAttrs)
DECLARE_DYNAMIC_ATTRIBUTE(ValveConfigurationAndControl::Attributes::OpenDuration::Id, INT32U, 4, 0), /* Open Duration */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these attributes should also be nullable by having ATTRIBUTE_MASK_NULLABLE.
The only ones which are not nullable are ValveFault and FeatureMap.
I noticed that in Home Assistant if I set the Default open duration to something other than 0 - it'll not let me go back to zero, possibly this is the cause for that.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update, I've tested it, however the Default open duration is now vanished from HA. The attributes are now correct however. This might be an issue on Home Assistant's side. Can you also please test it on your setup to see if you have the same issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll fix that issue:
home-assistant/core#177128

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's awesome! Thank you for going out and fixing the issue in HA.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch has been released in the dev branch for an upcoming beta release.

OpenDuration, DefaultOpenDuration, RemainingDuration, CurrentState and
TargetState are all nullable per spec, and OpenDuration/DefaultOpenDuration
have a min value of 1, so "no duration configured" must be represented as
null rather than 0. Without ATTRIBUTE_MASK_NULLABLE, writes of null (e.g.
clearing DefaultOpenDuration from Home Assistant) were rejected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community contribution PR contents contributed by the community Under review Request or issue under review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants