From 684347247484618a937ca526b5e373bc5d2e5209 Mon Sep 17 00:00:00 2001 From: Luke Bonaccorsi Date: Fri, 22 Mar 2024 00:35:35 +0000 Subject: [PATCH] fix: re-add consumables code --- custom_components/robovac/vacuum.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/custom_components/robovac/vacuum.py b/custom_components/robovac/vacuum.py index af87754..48ffafa 100644 --- a/custom_components/robovac/vacuum.py +++ b/custom_components/robovac/vacuum.py @@ -357,11 +357,16 @@ class RoboVacEntity(StateVacuumEntity): CONSUMABLE_CODE in self.tuyastatus and self.tuyastatus.get(CONSUMABLE_CODE) is not None ): - self._attr_consumables = ast.literal_eval( + consumables = ast.literal_eval( base64.b64decode(self.tuyastatus.get(CONSUMABLE_CODE)).decode( "ascii" ) - )["consumable"]["duration"] + ) + if ( + "consumable" in consumables + and "duration" in consumables["consumable"] + ): + self._attr_consumables = consumables["consumable"]["duration"] async def async_locate(self, **kwargs): """Locate the vacuum cleaner."""