mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 03:33:35 +00:00
Use .get instead of getattr on the dict
This commit is contained in:
parent
3c437fb297
commit
7721a4d388
@ -82,7 +82,7 @@ class VacuumConsumables(SmartModule):
|
|||||||
name=f"{consumable.name} used",
|
name=f"{consumable.name} used",
|
||||||
container=self.data,
|
container=self.data,
|
||||||
attribute_getter=lambda container, item=consumable: timedelta(
|
attribute_getter=lambda container, item=consumable: timedelta(
|
||||||
minutes=getattr(container, item.data_key)
|
minutes=container.get(item.data_key)
|
||||||
),
|
),
|
||||||
category=Feature.Category.Debug,
|
category=Feature.Category.Debug,
|
||||||
type=Feature.Type.Sensor,
|
type=Feature.Type.Sensor,
|
||||||
@ -96,7 +96,7 @@ class VacuumConsumables(SmartModule):
|
|||||||
name=f"{consumable.name} remaining",
|
name=f"{consumable.name} remaining",
|
||||||
container=self.data,
|
container=self.data,
|
||||||
attribute_getter=lambda container, item=consumable: item.lifetime
|
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,
|
category=Feature.Category.Info,
|
||||||
type=Feature.Type.Sensor,
|
type=Feature.Type.Sensor,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user