Skip to content

Commit 05ceee5

Browse files
authored
Honeywell: Don't use shared session (home-assistant#147772)
1 parent 08a6b38 commit 05ceee5

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

homeassistant/components/honeywell/__init__.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,9 @@
99
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform
1010
from homeassistant.core import HomeAssistant, callback
1111
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
12-
from homeassistant.helpers.aiohttp_client import (
13-
async_create_clientsession,
14-
async_get_clientsession,
15-
)
16-
17-
from .const import (
18-
_LOGGER,
19-
CONF_COOL_AWAY_TEMPERATURE,
20-
CONF_HEAT_AWAY_TEMPERATURE,
21-
DOMAIN,
22-
)
12+
from homeassistant.helpers.aiohttp_client import async_create_clientsession
13+
14+
from .const import _LOGGER, CONF_COOL_AWAY_TEMPERATURE, CONF_HEAT_AWAY_TEMPERATURE
2315

2416
UPDATE_LOOP_SLEEP_TIME = 5
2517
PLATFORMS = [Platform.CLIMATE, Platform.HUMIDIFIER, Platform.SENSOR, Platform.SWITCH]
@@ -56,11 +48,11 @@ async def async_setup_entry(
5648
username = config_entry.data[CONF_USERNAME]
5749
password = config_entry.data[CONF_PASSWORD]
5850

59-
if len(hass.config_entries.async_entries(DOMAIN)) > 1:
60-
session = async_create_clientsession(hass)
61-
else:
62-
session = async_get_clientsession(hass)
63-
51+
# Always create a new session for Honeywell to prevent cookie injection
52+
# issues. Even with response_url handling in aiosomecomfort 0.0.33+,
53+
# cookies can still leak into other integrations when using the shared
54+
# session. See issue #147395.
55+
session = async_create_clientsession(hass)
6456
client = aiosomecomfort.AIOSomeComfort(username, password, session=session)
6557
try:
6658
await client.login()

homeassistant/components/honeywell/config_flow.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
)
1717
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
1818
from homeassistant.core import callback
19-
from homeassistant.helpers.aiohttp_client import async_get_clientsession
19+
from homeassistant.helpers.aiohttp_client import async_create_clientsession
2020

2121
from .const import (
2222
CONF_COOL_AWAY_TEMPERATURE,
@@ -114,10 +114,14 @@ async def async_step_user(self, user_input=None) -> ConfigFlowResult:
114114

115115
async def is_valid(self, **kwargs) -> bool:
116116
"""Check if login credentials are valid."""
117+
# Always create a new session for Honeywell to prevent cookie injection
118+
# issues. Even with response_url handling in aiosomecomfort 0.0.33+,
119+
# cookies can still leak into other integrations when using the shared
120+
# session. See issue #147395.
117121
client = aiosomecomfort.AIOSomeComfort(
118122
kwargs[CONF_USERNAME],
119123
kwargs[CONF_PASSWORD],
120-
session=async_get_clientsession(self.hass),
124+
session=async_create_clientsession(self.hass),
121125
)
122126

123127
await client.login()

0 commit comments

Comments
 (0)