Initiate websession inside event loop (#24331)
parent
798b72e164
commit
ebc09017b8
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue