From 7721a4d38816714b104607f4768b63b5d44c8e61 Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Sun, 1 Dec 2024 02:16:34 +0100 Subject: [PATCH] Use .get instead of getattr on the dict --- kasa/smart/modules/vacuumconsumables.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kasa/smart/modules/vacuumconsumables.py b/kasa/smart/modules/vacuumconsumables.py index 49544067..66e8f48a 100644 --- a/kasa/smart/modules/vacuumconsumables.py +++ b/kasa/smart/modules/vacuumconsumables.py @@ -82,7 +82,7 @@ class VacuumConsumables(SmartModule): name=f"{consumable.name} used", container=self.data, attribute_getter=lambda container, item=consumable: timedelta( - minutes=getattr(container, item.data_key) + minutes=container.get(item.data_key) ), category=Feature.Category.Debug, type=Feature.Type.Sensor, @@ -96,7 +96,7 @@ class VacuumConsumables(SmartModule): name=f"{consumable.name} remaining", container=self.data, attribute_getter=lambda container, item=consumable: item.lifetime - - timedelta(minutes=getattr(container, item.data_key)), + - timedelta(minutes=container.get(item.data_key)), category=Feature.Category.Info, type=Feature.Type.Sensor, )