1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Inject session in Switchbot cloud (#159942)

This commit is contained in:
Joost Lekkerkerker
2025-12-29 21:18:34 +01:00
committed by GitHub
parent bfacf462bf
commit 78adeb837e
@@ -20,6 +20,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN, CONF_WEBHOOK_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN, ENTRY_TITLE
from .coordinator import SwitchBotCoordinator
@@ -309,7 +310,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
token = entry.data[CONF_API_TOKEN]
secret = entry.data[CONF_API_KEY]
api = SwitchBotAPI(token=token, secret=secret)
api = SwitchBotAPI(
token=token, secret=secret, session=async_get_clientsession(hass)
)
try:
devices = await api.list_devices()
except SwitchBotAuthenticationError as ex: