From 547fd7d352a42194ffc1de74bdc3ef4be35f00f1 Mon Sep 17 00:00:00 2001 From: "David F. Mulcahey" Date: Fri, 12 Mar 2021 21:06:37 -0500 Subject: [PATCH] fix exception on device removal (#47803) --- homeassistant/components/zha/core/gateway.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/zha/core/gateway.py b/homeassistant/components/zha/core/gateway.py index c57c7269723..3a65787cd48 100644 --- a/homeassistant/components/zha/core/gateway.py +++ b/homeassistant/components/zha/core/gateway.py @@ -347,7 +347,8 @@ class ZHAGateway: remove_tasks = [] for entity_ref in entity_refs: remove_tasks.append(entity_ref.remove_future) - await asyncio.wait(remove_tasks) + if remove_tasks: + await asyncio.wait(remove_tasks) reg_device = self.ha_device_registry.async_get(device.device_id) if reg_device is not None: self.ha_device_registry.async_remove_device(reg_device.id)