Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tado: Initiate websession inside event loop #24331

Merged
merged 1 commit into from
Jun 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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