From 23b218bc4444c9774279c74252653d9d1e10be3f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 5 Mar 2022 22:02:45 -1000 Subject: [PATCH] Add missing disconnect in elkm1 config flow validation (#67716) --- homeassistant/components/elkm1/config_flow.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/elkm1/config_flow.py b/homeassistant/components/elkm1/config_flow.py index b8cd89edae4..d68fce268a2 100644 --- a/homeassistant/components/elkm1/config_flow.py +++ b/homeassistant/components/elkm1/config_flow.py @@ -81,8 +81,11 @@ async def validate_input(data: dict[str, str], mac: str | None) -> dict[str, str ) elk.connect() - if not await async_wait_for_elk_to_sync(elk, LOGIN_TIMEOUT, VALIDATE_TIMEOUT): - raise InvalidAuth + try: + if not await async_wait_for_elk_to_sync(elk, LOGIN_TIMEOUT, VALIDATE_TIMEOUT): + raise InvalidAuth + finally: + elk.disconnect() short_mac = _short_mac(mac) if mac else None if prefix and prefix != short_mac: