From 0ed48c844d1ae3e809f3615b5687617d501d90a7 Mon Sep 17 00:00:00 2001 From: Markus Jacobsen Date: Tue, 23 Apr 2024 21:06:06 +0200 Subject: [PATCH] Bump mozart-api to 3.4.1.8.5 (#113745) --- .../components/bang_olufsen/__init__.py | 27 ++++++++++++------- .../components/bang_olufsen/manifest.json | 2 +- .../components/bang_olufsen/media_player.py | 4 ++- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/bang_olufsen/__init__.py b/homeassistant/components/bang_olufsen/__init__.py index 2488c2e64f5..07b9d0befe1 100644 --- a/homeassistant/components/bang_olufsen/__init__.py +++ b/homeassistant/components/bang_olufsen/__init__.py @@ -4,7 +4,11 @@ from __future__ import annotations from dataclasses import dataclass -from aiohttp.client_exceptions import ClientConnectorError +from aiohttp.client_exceptions import ( + ClientConnectorError, + ClientOSError, + ServerTimeoutError, +) from mozart_api.exceptions import ApiException from mozart_api.mozart_client import MozartClient @@ -44,12 +48,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: model=entry.data[CONF_MODEL], ) - client = MozartClient(host=entry.data[CONF_HOST], websocket_reconnect=True) + client = MozartClient(host=entry.data[CONF_HOST]) - # Check connection and try to initialize it. + # Check API and WebSocket connection try: - await client.get_battery_state(_request_timeout=3) - except (ApiException, ClientConnectorError, TimeoutError) as error: + await client.check_device_connection(True) + except* ( + ClientConnectorError, + ClientOSError, + ServerTimeoutError, + ApiException, + TimeoutError, + ) as error: await client.close_api_client() raise ConfigEntryNotReady(f"Unable to connect to {entry.title}") from error @@ -61,11 +71,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: client, ) - # Check and start WebSocket connection - if not await client.connect_notifications(remote_control=True): - raise ConfigEntryNotReady( - f"Unable to connect to {entry.title} WebSocket notification channel" - ) + # Start WebSocket connection + await client.connect_notifications(remote_control=True, reconnect=True) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/bang_olufsen/manifest.json b/homeassistant/components/bang_olufsen/manifest.json index 3c920a99d7f..f2b31293227 100644 --- a/homeassistant/components/bang_olufsen/manifest.json +++ b/homeassistant/components/bang_olufsen/manifest.json @@ -6,6 +6,6 @@ "documentation": "https://www.home-assistant.io/integrations/bang_olufsen", "integration_type": "device", "iot_class": "local_push", - "requirements": ["mozart-api==3.2.1.150.6"], + "requirements": ["mozart-api==3.4.1.8.5"], "zeroconf": ["_bangolufsen._tcp.local."] } diff --git a/homeassistant/components/bang_olufsen/media_player.py b/homeassistant/components/bang_olufsen/media_player.py index 935c057efc8..9f55790d711 100644 --- a/homeassistant/components/bang_olufsen/media_player.py +++ b/homeassistant/components/bang_olufsen/media_player.py @@ -363,7 +363,9 @@ class BangOlufsenMediaPlayer(BangOlufsenEntity, MediaPlayerEntity): def is_volume_muted(self) -> bool | None: """Boolean if volume is currently muted.""" if self._volume.muted and self._volume.muted.muted: - return self._volume.muted.muted + # The any return here is side effect of pydantic v2 compatibility + # This will be fixed in the future. + return self._volume.muted.muted # type: ignore[no-any-return] return None @property diff --git a/requirements_all.txt b/requirements_all.txt index 240606435ba..f212a8675e8 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1332,7 +1332,7 @@ motionblindsble==0.0.9 motioneye-client==0.3.14 # homeassistant.components.bang_olufsen -mozart-api==3.2.1.150.6 +mozart-api==3.4.1.8.5 # homeassistant.components.mullvad mullvad-api==1.0.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 51161b1afd3..8f318a24b5e 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1074,7 +1074,7 @@ motionblindsble==0.0.9 motioneye-client==0.3.14 # homeassistant.components.bang_olufsen -mozart-api==3.2.1.150.6 +mozart-api==3.4.1.8.5 # homeassistant.components.mullvad mullvad-api==1.0.0