Fix blocking call in Bang & Olufsen API client initialization (#126456)

* Update API

* Add fix for blocking call to load_default_certs
This commit is contained in:
Markus Jacobsen 2024-09-22 23:08:27 +02:00 committed by GitHub
parent b107b2c7bf
commit 113a792734
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -17,6 +17,7 @@ from homeassistant.const import CONF_HOST, CONF_MODEL, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.device_registry as dr
from homeassistant.util.ssl import get_default_context
from .const import DOMAIN
from .websocket import BangOlufsenWebsocket
@ -48,7 +49,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
model=entry.data[CONF_MODEL],
)
client = MozartClient(host=entry.data[CONF_HOST])
client = MozartClient(host=entry.data[CONF_HOST], ssl_context=get_default_context())
# Check API and WebSocket connection
try:

View file

@ -14,6 +14,7 @@ from homeassistant.components.zeroconf import ZeroconfServiceInfo
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_MODEL
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
from homeassistant.util.ssl import get_default_context
from .const import (
ATTR_FRIENDLY_NAME,
@ -88,7 +89,9 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN):
errors={"base": _exception_map[type(error)]},
)
self._client = MozartClient(self._host)
self._client = MozartClient(
host=self._host, ssl_context=get_default_context()
)
# Try to get information from Beolink self method.
async with self._client:
@ -137,7 +140,7 @@ class BangOlufsenConfigFlowHandler(ConfigFlow, domain=DOMAIN):
return self.async_abort(reason="ipv6_address")
# Check connection to ensure valid address is received
self._client = MozartClient(self._host)
self._client = MozartClient(self._host, ssl_context=get_default_context())
async with self._client:
try: