File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 11"""Module for discovering Roborock devices."""
22
3+ import asyncio
34import logging
45from collections .abc import Awaitable , Callable
56
@@ -56,6 +57,7 @@ async def discover_devices(self) -> list[RoborockDevice]:
5657 device_products = home_data .device_products
5758 _LOGGER .debug ("Discovered %d devices %s" , len (device_products ), home_data )
5859
60+ # These are connected serially to avoid overwhelming the MQTT broker
5961 new_devices = {}
6062 for duid , (device , product ) in device_products .items ():
6163 if duid in self ._devices :
@@ -77,11 +79,10 @@ async def get_devices(self) -> list[RoborockDevice]:
7779
7880 async def close (self ) -> None :
7981 """Close all MQTT connections and clean up resources."""
80- for device in self ._devices .values ():
81- await device .close ()
82+ tasks = [device .close () for device in self ._devices .values ()]
8283 self ._devices .clear ()
83- if self ._mqtt_session :
84- await self . _mqtt_session . close ( )
84+ tasks . append ( self ._mqtt_session . close ())
85+ await asyncio . gather ( * tasks )
8586
8687
8788def create_home_data_api (email : str , user_data : UserData ) -> HomeDataApi :
You can’t perform that action at this time.
0 commit comments