Bump mozart-api to 3.4.1.8.5 (#113745)

This commit is contained in:
Markus Jacobsen 2024-04-23 21:06:06 +02:00 committed by GitHub
parent cc9eab4c78
commit 0ed48c844d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 14 deletions

View file

@ -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)

View file

@ -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."]
}

View file

@ -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

View file

@ -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

View file

@ -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