From cbc034200d5396d95e15164b9788cb14cb44c4ad Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Fri, 13 Dec 2024 09:43:35 +0200 Subject: [PATCH] Ignore ConnectionError in disconnect() Fixes https://github.com/NitorCreations/ha-extron/issues/8 --- custom_components/extron/extron.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/custom_components/extron/extron.py b/custom_components/extron/extron.py index 33be466..9f9e322 100644 --- a/custom_components/extron/extron.py +++ b/custom_components/extron/extron.py @@ -69,8 +69,13 @@ async def connect(self): async def disconnect(self): self._connected = False - self._writer.close() - await self._writer.wait_closed() + + # Ignore potential connection errors here, we're about to disconnect after all + try: + self._writer.close() + await self._writer.wait_closed() + except ConnectionError: + pass async def reconnect(self): await self.disconnect()