diff --git a/homeassistant/components/bond/__init__.py b/homeassistant/components/bond/__init__.py index 0fafb61df35..800e1302517 100644 --- a/homeassistant/components/bond/__init__.py +++ b/homeassistant/components/bond/__init__.py @@ -10,6 +10,7 @@ from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr +from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.entity import SLOW_UPDATE_WARNING from .const import BPUP_STOP, BPUP_SUBS, BRIDGE_MAKE, DOMAIN, HUB @@ -25,7 +26,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: token = entry.data[CONF_ACCESS_TOKEN] config_entry_id = entry.entry_id - bond = Bond(host=host, token=token, timeout=ClientTimeout(total=_API_TIMEOUT)) + bond = Bond( + host=host, + token=token, + timeout=ClientTimeout(total=_API_TIMEOUT), + session=async_get_clientsession(hass), + ) hub = BondHub(bond) try: await hub.setup() diff --git a/homeassistant/components/bond/config_flow.py b/homeassistant/components/bond/config_flow.py index 763a0957876..2e1f106193e 100644 --- a/homeassistant/components/bond/config_flow.py +++ b/homeassistant/components/bond/config_flow.py @@ -15,6 +15,8 @@ from homeassistant.const import ( CONF_NAME, HTTP_UNAUTHORIZED, ) +from homeassistant.core import HomeAssistant +from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.typing import DiscoveryInfoType from .const import DOMAIN @@ -30,10 +32,12 @@ DISCOVERY_SCHEMA = vol.Schema({vol.Required(CONF_ACCESS_TOKEN): str}) TOKEN_SCHEMA = vol.Schema({}) -async def _validate_input(data: dict[str, Any]) -> tuple[str, str]: +async def _validate_input(hass: HomeAssistant, data: dict[str, Any]) -> tuple[str, str]: """Validate the user input allows us to connect.""" - bond = Bond(data[CONF_HOST], data[CONF_ACCESS_TOKEN]) + bond = Bond( + data[CONF_HOST], data[CONF_ACCESS_TOKEN], session=async_get_clientsession(hass) + ) try: hub = BondHub(bond) await hub.setup(max_devices=1) @@ -71,7 +75,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): online longer then the allowed setup period, and we will instead ask them to manually enter the token. """ - bond = Bond(self._discovered[CONF_HOST], "") + bond = Bond( + self._discovered[CONF_HOST], "", session=async_get_clientsession(self.hass) + ) try: response = await bond.token() except ClientConnectionError: @@ -82,7 +88,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): return self._discovered[CONF_ACCESS_TOKEN] = token - _, hub_name = await _validate_input(self._discovered) + _, hub_name = await _validate_input(self.hass, self._discovered) self._discovered[CONF_NAME] = hub_name async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType) -> dict[str, Any]: # type: ignore @@ -127,7 +133,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): CONF_HOST: self._discovered[CONF_HOST], } try: - _, hub_name = await _validate_input(data) + _, hub_name = await _validate_input(self.hass, data) except InputValidationError as error: errors["base"] = error.base else: @@ -155,7 +161,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): errors = {} if user_input is not None: try: - bond_id, hub_name = await _validate_input(user_input) + bond_id, hub_name = await _validate_input(self.hass, user_input) except InputValidationError as error: errors["base"] = error.base else: diff --git a/homeassistant/components/bond/manifest.json b/homeassistant/components/bond/manifest.json index 65cb6a83bb2..7204ac7e91d 100644 --- a/homeassistant/components/bond/manifest.json +++ b/homeassistant/components/bond/manifest.json @@ -3,7 +3,7 @@ "name": "Bond", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/bond", - "requirements": ["bond-api==0.1.11"], + "requirements": ["bond-api==0.1.12"], "zeroconf": ["_bond._tcp.local."], "codeowners": ["@prystupa"], "quality_scale": "platinum" diff --git a/requirements_all.txt b/requirements_all.txt index f1f5128a790..df497eb889a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -374,7 +374,7 @@ blockchain==1.4.4 # bme680==1.0.5 # homeassistant.components.bond -bond-api==0.1.11 +bond-api==0.1.12 # homeassistant.components.amazon_polly # homeassistant.components.route53 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index cfbaa1fa0b5..91dc8ff600e 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -208,7 +208,7 @@ blebox_uniapi==1.3.2 blinkpy==0.17.0 # homeassistant.components.bond -bond-api==0.1.11 +bond-api==0.1.12 # homeassistant.components.braviatv bravia-tv==1.0.8