File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
homeassistant/components/matter Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -52,9 +52,12 @@ async def async_close_valve(self) -> None:
5252
5353 async def async_set_valve_position (self , position : int ) -> None :
5454 """Move the valve to a specific position."""
55- await self .send_device_command (
56- ValveConfigurationAndControl .Commands .Open (targetLevel = position )
57- )
55+ if position > 0 :
56+ await self .send_device_command (
57+ ValveConfigurationAndControl .Commands .Open (targetLevel = position )
58+ )
59+ return
60+ await self .send_device_command (ValveConfigurationAndControl .Commands .Close ())
5861
5962 @callback
6063 def _update_from_device (self ) -> None :
Original file line number Diff line number Diff line change @@ -133,3 +133,22 @@ async def test_valve(
133133 command = clusters .ValveConfigurationAndControl .Commands .Open (targetLevel = 100 ),
134134 )
135135 matter_client .send_device_command .reset_mock ()
136+
137+ # test using set_position action to close valve
138+ await hass .services .async_call (
139+ "valve" ,
140+ "set_valve_position" ,
141+ {
142+ "entity_id" : entity_id ,
143+ "position" : 0 ,
144+ },
145+ blocking = True ,
146+ )
147+
148+ assert matter_client .send_device_command .call_count == 1
149+ assert matter_client .send_device_command .call_args == call (
150+ node_id = matter_node .node_id ,
151+ endpoint_id = 1 ,
152+ command = clusters .ValveConfigurationAndControl .Commands .Close (),
153+ )
154+ matter_client .send_device_command .reset_mock ()
You can’t perform that action at this time.
0 commit comments