diff --git a/homeassistant/components/tado/device_tracker.py b/homeassistant/components/tado/device_tracker.py index 3bb62f328b9..31b424b9cd4 100644 --- a/homeassistant/components/tado/device_tracker.py +++ b/homeassistant/components/tado/device_tracker.py @@ -42,6 +42,7 @@ class TadoDeviceScanner(DeviceScanner): def __init__(self, hass, config): """Initialize the scanner.""" + self.hass = hass self.last_results = [] self.username = config[CONF_USERNAME] @@ -60,8 +61,7 @@ class TadoDeviceScanner(DeviceScanner): # The API URL always needs a username and password self.tadoapiurl += '?username={username}&password={password}' - self.websession = async_create_clientsession( - hass, cookie_jar=aiohttp.CookieJar(unsafe=True)) + self.websession = None self.success_init = asyncio.run_coroutine_threadsafe( self._async_update_info(), hass.loop @@ -92,6 +92,10 @@ class TadoDeviceScanner(DeviceScanner): """ _LOGGER.debug("Requesting Tado") + if self.websession is None: + self.websession = async_create_clientsession( + self.hass, cookie_jar=aiohttp.CookieJar(unsafe=True)) + last_results = [] try: