Răsfoiți Sursa

Add support for moebot stop to vacuum

kytro 2 ani în urmă
părinte
comite
c450038ccd
1 a modificat fișierele cu 9 adăugiri și 0 ștergeri
  1. 9 0
      custom_components/tuya_local/vacuum.py

+ 9 - 0
custom_components/tuya_local/vacuum.py

@@ -4,6 +4,7 @@ Setup for different kinds of Tuya vacuum cleaners
 from homeassistant.components.vacuum import (
     SERVICE_CLEAN_SPOT,
     SERVICE_RETURN_TO_BASE,
+    SERVICE_STOP,
     STATE_CLEANING,
     STATE_DOCKED,
     STATE_RETURNING,
@@ -76,6 +77,8 @@ class TuyaLocalVacuum(TuyaLocalEntity, StateVacuumEntity):
             support |= VacuumEntityFeature.RETURN_HOME
         if SERVICE_CLEAN_SPOT in cmd_support:
             support |= VacuumEntityFeature.CLEAN_SPOT
+        if SERVICE_STOP in cmd_support:
+            support |= VacuumEntityFeature.STOP
 
         if self._active_dps:
             support |= VacuumEntityFeature.START | VacuumEntityFeature.PAUSE
@@ -162,6 +165,12 @@ class TuyaLocalVacuum(TuyaLocalEntity, StateVacuumEntity):
         dps = self._command_dps or self._status_dps
         if dps and SERVICE_CLEAN_SPOT in dps.values(self._device):
             await dps.async_set_value(self._device, SERVICE_CLEAN_SPOT)
+        
+    async def async_stop(self, **kwargs):
+        """Tell the vacuum cleaner to stop."""
+        dps = self._command_dps or self._status_dps
+        if dps and SERVICE_STOP in dps.values(self._device):
+            await dps.async_set_value(self._device, SERVICE_STOP)
 
     async def async_locate(self, **kwargs):
         """Locate the vacuum cleaner."""