diff --git a/custom_components/sonoff/core/ewelink/__init__.py b/custom_components/sonoff/core/ewelink/__init__.py index 7baf9f70..c49a7e0c 100644 --- a/custom_components/sonoff/core/ewelink/__init__.py +++ b/custom_components/sonoff/core/ewelink/__init__.py @@ -158,12 +158,15 @@ async def send_bulk(self, device: XDevice, params: dict): break else: device["params_bulk"]["switches"].append(new) - return + else: + device["params_bulk"] = params - device["params_bulk"] = params await asyncio.sleep(0.1) - return await self.send(device, device.pop("params_bulk")) + # this can be called from different threads/loops + # https://github.com/AlexxIT/SonoffLAN/issues/1368 + if params := device.pop("params_bulk", None): + return await self.send(device, params) async def send_cloud(self, device: XDevice, params: dict = None, query=True): if not self.can_cloud(device):