mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +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):
|
def __init__(self, hass, config):
|
||||||
"""Initialize the scanner."""
|
"""Initialize the scanner."""
|
||||||
|
self.hass = hass
|
||||||
self.last_results = []
|
self.last_results = []
|
||||||
|
|
||||||
self.username = config[CONF_USERNAME]
|
self.username = config[CONF_USERNAME]
|
||||||
@ -60,8 +61,7 @@ class TadoDeviceScanner(DeviceScanner):
|
|||||||
# The API URL always needs a username and password
|
# The API URL always needs a username and password
|
||||||
self.tadoapiurl += '?username={username}&password={password}'
|
self.tadoapiurl += '?username={username}&password={password}'
|
||||||
|
|
||||||
self.websession = async_create_clientsession(
|
self.websession = None
|
||||||
hass, cookie_jar=aiohttp.CookieJar(unsafe=True))
|
|
||||||
|
|
||||||
self.success_init = asyncio.run_coroutine_threadsafe(
|
self.success_init = asyncio.run_coroutine_threadsafe(
|
||||||
self._async_update_info(), hass.loop
|
self._async_update_info(), hass.loop
|
||||||
@ -92,6 +92,10 @@ class TadoDeviceScanner(DeviceScanner):
|
|||||||
"""
|
"""
|
||||||
_LOGGER.debug("Requesting Tado")
|
_LOGGER.debug("Requesting Tado")
|
||||||
|
|
||||||
|
if self.websession is None:
|
||||||
|
self.websession = async_create_clientsession(
|
||||||
|
self.hass, cookie_jar=aiohttp.CookieJar(unsafe=True))
|
||||||
|
|
||||||
last_results = []
|
last_results = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user