mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Always create a new session in ConfigFlow in Overkiz integration (#66602)
This commit is contained in:
parent
5568531f74
commit
98ae7e106c
@ -19,7 +19,7 @@ from homeassistant.components import dhcp, zeroconf
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.data_entry_flow import FlowResult
|
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
|
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]
|
username = user_input[CONF_USERNAME]
|
||||||
password = user_input[CONF_PASSWORD]
|
password = user_input[CONF_PASSWORD]
|
||||||
server = SUPPORTED_SERVERS[user_input[CONF_HUB]]
|
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
|
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():
|
||||||
# Set first gateway id as unique id
|
gateway_id = gateways[0].id
|
||||||
if gateways := await client.get_gateways():
|
await self.async_set_unique_id(gateway_id)
|
||||||
gateway_id = gateways[0].id
|
|
||||||
await self.async_set_unique_id(gateway_id)
|
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user