Skip to content

Commit

Permalink
Initiate websession inside event loop (#24331)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Jun 8, 2019
1 parent 798b72e commit ebc0901
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions homeassistant/components/tado/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -60,8 +61,7 @@ def __init__(self, hass, config):
# 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
Expand Down Expand Up @@ -92,6 +92,10 @@ async def _async_update_info(self):
"""
_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:
Expand Down

0 comments on commit ebc0901

Please sign in to comment.