From 6a32b9bf87b3b3d68dbd9a43d31cec36423c27e6 Mon Sep 17 00:00:00 2001 From: Dan Cinnamon Date: Sun, 5 Aug 2018 11:51:23 -0500 Subject: [PATCH] Fix envisalink reconnect (#15832) * Fix logic for handling connection lost/reconnect * Fixed line length issue. --- homeassistant/components/envisalink.py | 14 +++++++++----- requirements_all.txt | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/envisalink.py b/homeassistant/components/envisalink.py index 7dd4e7dc32a..9b5b25c934c 100644 --- a/homeassistant/components/envisalink.py +++ b/homeassistant/components/envisalink.py @@ -16,7 +16,7 @@ from homeassistant.helpers.entity import Entity from homeassistant.helpers.discovery import async_load_platform from homeassistant.helpers.dispatcher import async_dispatcher_send -REQUIREMENTS = ['pyenvisalink==2.2'] +REQUIREMENTS = ['pyenvisalink==2.3'] _LOGGER = logging.getLogger(__name__) @@ -111,20 +111,24 @@ def async_setup(hass, config): def login_fail_callback(data): """Handle when the evl rejects our login.""" _LOGGER.error("The Envisalink rejected your credentials") - sync_connect.set_result(False) + if not sync_connect.done(): + sync_connect.set_result(False) @callback def connection_fail_callback(data): """Network failure callback.""" _LOGGER.error("Could not establish a connection with the Envisalink") - sync_connect.set_result(False) + if not sync_connect.done(): + sync_connect.set_result(False) @callback def connection_success_callback(data): """Handle a successful connection.""" _LOGGER.info("Established a connection with the Envisalink") - hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_envisalink) - sync_connect.set_result(True) + if not sync_connect.done(): + hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, + stop_envisalink) + sync_connect.set_result(True) @callback def zones_updated_callback(data): diff --git a/requirements_all.txt b/requirements_all.txt index 2c7873175f4..19da051c452 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -826,7 +826,7 @@ pyeight==0.0.9 pyemby==1.5 # homeassistant.components.envisalink -pyenvisalink==2.2 +pyenvisalink==2.3 # homeassistant.components.climate.ephember pyephember==0.1.1