Skip to content

Commit

Permalink
create separate aiohttp ClientSession for config flow
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertD502 authored Aug 4, 2023
1 parent 59f635b commit 8efc213
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/coway/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_create_clientsession
import homeassistant.helpers.config_validation as cv

from .const import DEFAULT_NAME, DOMAIN, SKIP_PASSWORD_CHANGE
Expand Down Expand Up @@ -59,7 +60,8 @@ async def async_step_reauth_confirm(
password = user_input[CONF_PASSWORD]
skip_password_change = user_input[SKIP_PASSWORD_CHANGE] if SKIP_PASSWORD_CHANGE in user_input else False
try:
await async_validate_api(username, password, skip_password_change)
session = async_create_clientsession(self.hass)
await async_validate_api(self.hass, username, password, skip_password_change, session)
except AuthError:
errors["base"] = "invalid_auth"
except ConnectionError:
Expand Down Expand Up @@ -101,7 +103,8 @@ async def async_step_user(
password = user_input[CONF_PASSWORD]
skip_password_change = user_input[SKIP_PASSWORD_CHANGE] if SKIP_PASSWORD_CHANGE in user_input else False
try:
await async_validate_api(username, password, skip_password_change)
session = async_create_clientsession(self.hass)
await async_validate_api(self.hass, username, password, skip_password_change, session)
except AuthError:
errors["base"] = "invalid_auth"
except ConnectionError:
Expand Down

0 comments on commit 8efc213

Please sign in to comment.