Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion homeassistant/components/bang_olufsen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/bang_olufsen/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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,
Expand Down Expand Up @@ -88,7 +89,9 @@ async def async_step_user(
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:
Expand Down Expand Up @@ -137,7 +140,7 @@ async def async_step_zeroconf(
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:
Expand Down