Always create a new session in ConfigFlow in Overkiz integration (#66602)

pull/66610/head
Mick Vleeshouwer 2022-02-15 12:46:52 -08:00 committed by GitHub
parent 5568531f74
commit 98ae7e106c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 10 deletions

View File

@ -19,7 +19,7 @@ from homeassistant.components import dhcp, zeroconf
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from .const import CONF_HUB, DEFAULT_HUB, DOMAIN, LOGGER
@ -46,18 +46,17 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
username = user_input[CONF_USERNAME]
password = user_input[CONF_PASSWORD]
server = SUPPORTED_SERVERS[user_input[CONF_HUB]]
session = async_get_clientsession(self.hass)
session = async_create_clientsession(self.hass)
client = OverkizClient(
async with OverkizClient(
username=username, password=password, server=server, session=session
)
) as client:
await client.login()
await client.login()
# Set first gateway id as unique id
if gateways := await client.get_gateways():
gateway_id = gateways[0].id
await self.async_set_unique_id(gateway_id)
# Set first gateway id as unique id
if gateways := await client.get_gateways():
gateway_id = gateways[0].id
await self.async_set_unique_id(gateway_id)
async def async_step_user(
self, user_input: dict[str, Any] | None = None