From 81d018ce252a28c8e7d8f21ce6a54bddeeaaa5d2 Mon Sep 17 00:00:00 2001 From: Adam Kingsley Date: Wed, 23 Oct 2024 15:00:07 +0200 Subject: [PATCH] Add method to clear devices from FreeAtHome class (#68) --- src/abbfreeathome/freeathome.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/abbfreeathome/freeathome.py b/src/abbfreeathome/freeathome.py index 939f2fc..8a803ca 100644 --- a/src/abbfreeathome/freeathome.py +++ b/src/abbfreeathome/freeathome.py @@ -35,6 +35,10 @@ def __init__( self._device_classes: list[Base] = device_classes self._include_orphan_channels = include_orphan_channels + def clear_devices(self): + """Clear all devices in the device list.""" + self._devices.clear() + async def get_config(self, refresh: bool = False) -> dict: """Get the Free@Home Configuration.""" if self._config is None or refresh: @@ -134,6 +138,7 @@ def get_device_by_class(self, device_class: Base) -> list[Base]: async def load_devices(self): """Load all of the devices into the devices object.""" + self.clear_devices() for _mapping in self._get_function_to_device_mapping(): await self._load_devices_by_function( _mapping.get("function"), _mapping.get("device_class")