Matter valve Open command doesn't support TargetLevel=0 (#150922)

This commit is contained in:
Calvin Walton
2025-08-21 10:19:14 -04:00
committed by Paulus Schoutsen
parent 1bd5aa0ab0
commit bb9660269c
2 changed files with 25 additions and 3 deletions

View File

@@ -52,9 +52,12 @@ class MatterValve(MatterEntity, ValveEntity):
async def async_set_valve_position(self, position: int) -> None:
"""Move the valve to a specific position."""
await self.send_device_command(
ValveConfigurationAndControl.Commands.Open(targetLevel=position)
)
if position > 0:
await self.send_device_command(
ValveConfigurationAndControl.Commands.Open(targetLevel=position)
)
return
await self.send_device_command(ValveConfigurationAndControl.Commands.Close())
@callback
def _update_from_device(self) -> None:

View File

@@ -133,3 +133,22 @@ async def test_valve(
command=clusters.ValveConfigurationAndControl.Commands.Open(targetLevel=100),
)
matter_client.send_device_command.reset_mock()
# test using set_position action to close valve
await hass.services.async_call(
"valve",
"set_valve_position",
{
"entity_id": entity_id,
"position": 0,
},
blocking=True,
)
assert matter_client.send_device_command.call_count == 1
assert matter_client.send_device_command.call_args == call(
node_id=matter_node.node_id,
endpoint_id=1,
command=clusters.ValveConfigurationAndControl.Commands.Close(),
)
matter_client.send_device_command.reset_mock()