From 356c6c0314100d67218c884e16302343120f4ef6 Mon Sep 17 00:00:00 2001 From: SLaks Date: Tue, 19 Mar 2024 11:48:13 -0400 Subject: [PATCH] Roborock: Add clean_percent Note: Only newer models have this (Q Revo is the only one I know of). HA shows the sensor as `unknown` for other models; I don't know how to exclude it. --- miio/integrations/roborock/vacuum/vacuumcontainers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/miio/integrations/roborock/vacuum/vacuumcontainers.py b/miio/integrations/roborock/vacuum/vacuumcontainers.py index 7af2afce8..65a5963a3 100644 --- a/miio/integrations/roborock/vacuum/vacuumcontainers.py +++ b/miio/integrations/roborock/vacuum/vacuumcontainers.py @@ -204,6 +204,14 @@ def vacuum_state(self) -> VacuumState: """Return vacuum state.""" return STATE_CODE_TO_VACUUMSTATE.get(self.state_code, VacuumState.Unknown) + @property + @sensor("Cleaning Progress", icon="mdi:progress-check", unit="%") + def clean_percent(self) -> Optional[int]: + """Return progress of the current clean.""" + if "clean_percent" in self.data: + return int(self.data["clean_percent"]) + return None + @property @sensor( "Error code",