mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Honeywell: Don't use shared session (#147772)
This commit is contained in:
parent
08a6b38699
commit
05ceee568e
@ -9,17 +9,9 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
from homeassistant.helpers.aiohttp_client import (
|
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||||
async_create_clientsession,
|
|
||||||
async_get_clientsession,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import (
|
from .const import _LOGGER, CONF_COOL_AWAY_TEMPERATURE, CONF_HEAT_AWAY_TEMPERATURE
|
||||||
_LOGGER,
|
|
||||||
CONF_COOL_AWAY_TEMPERATURE,
|
|
||||||
CONF_HEAT_AWAY_TEMPERATURE,
|
|
||||||
DOMAIN,
|
|
||||||
)
|
|
||||||
|
|
||||||
UPDATE_LOOP_SLEEP_TIME = 5
|
UPDATE_LOOP_SLEEP_TIME = 5
|
||||||
PLATFORMS = [Platform.CLIMATE, Platform.HUMIDIFIER, Platform.SENSOR, Platform.SWITCH]
|
PLATFORMS = [Platform.CLIMATE, Platform.HUMIDIFIER, Platform.SENSOR, Platform.SWITCH]
|
||||||
@ -56,11 +48,11 @@ async def async_setup_entry(
|
|||||||
username = config_entry.data[CONF_USERNAME]
|
username = config_entry.data[CONF_USERNAME]
|
||||||
password = config_entry.data[CONF_PASSWORD]
|
password = config_entry.data[CONF_PASSWORD]
|
||||||
|
|
||||||
if len(hass.config_entries.async_entries(DOMAIN)) > 1:
|
# Always create a new session for Honeywell to prevent cookie injection
|
||||||
|
# issues. Even with response_url handling in aiosomecomfort 0.0.33+,
|
||||||
|
# cookies can still leak into other integrations when using the shared
|
||||||
|
# session. See issue #147395.
|
||||||
session = async_create_clientsession(hass)
|
session = async_create_clientsession(hass)
|
||||||
else:
|
|
||||||
session = async_get_clientsession(hass)
|
|
||||||
|
|
||||||
client = aiosomecomfort.AIOSomeComfort(username, password, session=session)
|
client = aiosomecomfort.AIOSomeComfort(username, password, session=session)
|
||||||
try:
|
try:
|
||||||
await client.login()
|
await client.login()
|
||||||
|
@ -16,7 +16,7 @@ from homeassistant.config_entries import (
|
|||||||
)
|
)
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_COOL_AWAY_TEMPERATURE,
|
CONF_COOL_AWAY_TEMPERATURE,
|
||||||
@ -114,10 +114,14 @@ class HoneywellConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
async def is_valid(self, **kwargs) -> bool:
|
async def is_valid(self, **kwargs) -> bool:
|
||||||
"""Check if login credentials are valid."""
|
"""Check if login credentials are valid."""
|
||||||
|
# Always create a new session for Honeywell to prevent cookie injection
|
||||||
|
# issues. Even with response_url handling in aiosomecomfort 0.0.33+,
|
||||||
|
# cookies can still leak into other integrations when using the shared
|
||||||
|
# session. See issue #147395.
|
||||||
client = aiosomecomfort.AIOSomeComfort(
|
client = aiosomecomfort.AIOSomeComfort(
|
||||||
kwargs[CONF_USERNAME],
|
kwargs[CONF_USERNAME],
|
||||||
kwargs[CONF_PASSWORD],
|
kwargs[CONF_PASSWORD],
|
||||||
session=async_get_clientsession(self.hass),
|
session=async_create_clientsession(self.hass),
|
||||||
)
|
)
|
||||||
|
|
||||||
await client.login()
|
await client.login()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user