Create new websession if more than one entry in Tesla (#47886)

* Create new websession if more than one entry
closes #47506

* Remove extraneous count

* Always create new session

* Update docs
This commit is contained in:
Alan Tse 2021-03-29 21:50:41 -07:00 committed by GitHub
parent 2956eb0902
commit 984fb12fa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -133,7 +133,8 @@ async def async_setup_entry(hass, config_entry):
"""Set up Tesla as config entry."""
hass.data.setdefault(DOMAIN, {})
config = config_entry.data
websession = aiohttp_client.async_get_clientsession(hass)
# Because users can have multiple accounts, we always create a new session so they have separate cookies
websession = aiohttp_client.async_create_clientsession(hass)
email = config_entry.title
if email in hass.data[DOMAIN] and CONF_SCAN_INTERVAL in hass.data[DOMAIN][email]:
scan_interval = hass.data[DOMAIN][email][CONF_SCAN_INTERVAL]

View File

@ -147,7 +147,8 @@ async def validate_input(hass: core.HomeAssistant, data):
"""
config = {}
websession = aiohttp_client.async_get_clientsession(hass)
websession = aiohttp_client.async_create_clientsession(hass)
try:
controller = TeslaAPI(
websession,