Add mute command to Bluesound integration (#41501)

Adding mute as a separate command as per the Bluesound API, rather than the current pseudo-mute which is achieved via lowering the volume to 0 then detecting whether the volume is 0 < volume < 0.001
pull/41504/head
willholdoway 2020-10-08 19:20:39 +01:00 committed by GitHub
parent 0856d91b0e
commit 1e9e0c8686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 12 deletions

View File

@ -220,7 +220,7 @@ class BluesoundPlayer(MediaPlayerEntity):
self._last_status_update = None
self._is_online = False
self._retry_remove = None
self._lastvol = None
self._muted = False
self._master = None
self._is_master = False
self._group_name = None
@ -660,10 +660,13 @@ class BluesoundPlayer(MediaPlayerEntity):
@property
def is_volume_muted(self):
"""Boolean if volume is currently muted."""
volume = self.volume_level
if not volume:
return None
return 0 <= volume < 0.001
mute = self._status.get("mute")
if self.is_grouped:
mute = self._sync_status.get("@mute")
if mute is not None:
mute = bool(int(mute))
return mute
@property
def name(self):
@ -1044,10 +1047,5 @@ class BluesoundPlayer(MediaPlayerEntity):
async def async_mute_volume(self, mute):
"""Send mute command to media player."""
if mute:
volume = self.volume_level
if volume > 0:
self._lastvol = volume
return await self.send_bluesound_command("Volume?level=0")
return await self.send_bluesound_command(
f"Volume?level={float(self._lastvol) * 100}"
)
return await self.send_bluesound_command("Volume?mute=1")
return await self.send_bluesound_command("Volume?mute=0")