mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Initiate websession inside event loop (#24331)
This commit is contained in:
parent
9ca5bdda7f
commit
d261c6ccc1
@ -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…
x
Reference in New Issue
Block a user