From 8e6e311bfcc771cb0766ecd6f913f9dcf300992a Mon Sep 17 00:00:00 2001 From: Dennis Melzer Date: Tue, 19 Dec 2023 10:03:22 +0100 Subject: [PATCH] Fix the missing error key --- custom_components/robovac/vacuum.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/robovac/vacuum.py b/custom_components/robovac/vacuum.py index bd38ba8..6b94239 100644 --- a/custom_components/robovac/vacuum.py +++ b/custom_components/robovac/vacuum.py @@ -359,11 +359,13 @@ 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: + self._attr_consumables = consumables["consumable"]["duration"] async def async_locate(self, **kwargs): """Locate the vacuum cleaner."""