Quellcode durchsuchen

vacuum: in send_command prefer the stop direction command.

Since the stop command for turning the vacuum off has a dedicated
`stop` action, in the `send_command` action prefer the direction
stop command so both can co-exist without renaming.

The need for this was highlighted after changing standby to stop to
expose the stop action on more vacuums in commit 5af8b5c7, when some
of the unit tests failed when triggered by a python code change later,
due to the direction previously using stop (which was probably the
reason why standby was used for the general command)
Jason Rumney vor 1 Jahr
Ursprung
Commit
c139a2564b
1 geänderte Dateien mit 9 neuen und 0 gelöschten Zeilen
  1. 9 0
      custom_components/tuya_local/vacuum.py

+ 9 - 0
custom_components/tuya_local/vacuum.py

@@ -176,6 +176,15 @@ class TuyaLocalVacuum(TuyaLocalEntity, StateVacuumEntity):
     async def async_send_command(self, command, params=None, **kwargs):
         """Send a command to the vacuum cleaner."""
         dps = self._command_dps or self._status_dps
+        # stop command is often present in both command and direction dps
+        # in that case, prefer the direction dp as async_stop will cover
+        # the commad dp seperately.
+        if (
+            command == SERVICE_STOP
+            and self._direction_dps
+            and SERVICE_STOP in self._direction_dps.values(self._device)
+        ):
+            dps = self._direction_dps
         if command in dps.values(self._device):
             await dps.async_set_value(self._device, command)
         elif self._direction_dps and command in self._direction_dps.values(