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

* Update API

* Add fix for blocking call to load_default_certs
pull/126566/head
Markus Jacobsen 2024-09-22 23:08:27 +02:00 committed by Franck Nijhof
parent c9571126a3
commit 08b0064ce7
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
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.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.device_registry as dr import homeassistant.helpers.device_registry as dr
from homeassistant.util.ssl import get_default_context
from .const import DOMAIN from .const import DOMAIN
from .websocket import BangOlufsenWebsocket from .websocket import BangOlufsenWebsocket
@ -48,7 +49,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
model=entry.data[CONF_MODEL], 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 # Check API and WebSocket connection
try: try:

View File

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