diff --git a/custom_components/bangolufsen/manifest.json b/custom_components/bangolufsen/manifest.json index 9307e3b..88c437e 100644 --- a/custom_components/bangolufsen/manifest.json +++ b/custom_components/bangolufsen/manifest.json @@ -8,6 +8,6 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/bang-olufsen/bangolufsen-hacs/issues", "requirements": ["mozart-api==3.2.1.150.5"], - "version": "1.6.0", + "version": "1.6.1", "zeroconf": ["_bangolufsen._tcp.local."] } diff --git a/custom_components/bangolufsen/media_player.py b/custom_components/bangolufsen/media_player.py index bb38417..6f56138 100644 --- a/custom_components/bangolufsen/media_player.py +++ b/custom_components/bangolufsen/media_player.py @@ -236,6 +236,7 @@ class BangOlufsenMediaPlayer(MediaPlayerEntity, CoordinatorEntity, BangOlufsenEn def __init__(self, entry: ConfigEntry, data: BangOlufsenData) -> None: """Initialize the media player.""" + MediaPlayerEntity.__init__(self) CoordinatorEntity.__init__(self, data.coordinator) BangOlufsenEntity.__init__(self, entry, data.client) @@ -1301,16 +1302,18 @@ async def async_overlay_audio( _LOGGER.error("Can't define URI and TTS message at the same time") return - volume = None + overlay_play_request = OverlayPlayRequest() if absolute_volume: - volume = absolute_volume + overlay_play_request.volume_absolute = absolute_volume elif volume_offset: # Ensure that the volume is not above 100 if not self._volume.level or not self._volume.level.level: _LOGGER.warning("Error setting volume") else: - volume = min(self._volume.level.level + volume_offset, 100) + overlay_play_request.volume_absolute = min( + self._volume.level.level + volume_offset, 100 + ) if uri: media_id = uri @@ -1323,18 +1326,11 @@ async def async_overlay_audio( media_id = async_process_play_media_url(self.hass, sourced_media.url) - await self._client.post_overlay_play( - overlay_play_request=OverlayPlayRequest( - uri=Uri(location=media_id), volume_absolute=volume - ) - ) + overlay_play_request.uri = Uri(location=media_id) elif tts: - await self._client.post_overlay_play( - overlay_play_request=OverlayPlayRequest( - text_to_speech=OverlayPlayRequestTextToSpeechTextToSpeech( - lang=tts_language, text=tts - ), - volume_absolute=volume, - ) + overlay_play_request.text_to_speech = ( + OverlayPlayRequestTextToSpeechTextToSpeech(lang=tts_language, text=tts) ) + + await self._client.post_overlay_play(overlay_play_request)