From 1012d823a04f7c36c4660791ff0e7f8caee1a868 Mon Sep 17 00:00:00 2001 From: Emilv2 Date: Mon, 2 Aug 2021 14:54:33 +0200 Subject: [PATCH] Fix missing default reconnect interval in dsmr (#53760) --- homeassistant/components/dsmr/sensor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index 5afc229a727..faff62ddeb4 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -157,7 +157,9 @@ async def async_setup_entry( update_entities_telegram({}) # throttle reconnect attempts - await asyncio.sleep(entry.data[CONF_RECONNECT_INTERVAL]) + await asyncio.sleep( + entry.data.get(CONF_RECONNECT_INTERVAL, DEFAULT_RECONNECT_INTERVAL) + ) except (serial.serialutil.SerialException, OSError): # Log any error while establishing connection and drop to retry @@ -167,7 +169,9 @@ async def async_setup_entry( protocol = None # throttle reconnect attempts - await asyncio.sleep(entry.data[CONF_RECONNECT_INTERVAL]) + await asyncio.sleep( + entry.data.get(CONF_RECONNECT_INTERVAL, DEFAULT_RECONNECT_INTERVAL) + ) except CancelledError: if stop_listener: stop_listener() # pylint: disable=not-callable