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.001pull/41504/head
parent
0856d91b0e
commit
1e9e0c8686
|
@ -220,7 +220,7 @@ class BluesoundPlayer(MediaPlayerEntity):
|
||||||
self._last_status_update = None
|
self._last_status_update = None
|
||||||
self._is_online = False
|
self._is_online = False
|
||||||
self._retry_remove = None
|
self._retry_remove = None
|
||||||
self._lastvol = None
|
self._muted = False
|
||||||
self._master = None
|
self._master = None
|
||||||
self._is_master = False
|
self._is_master = False
|
||||||
self._group_name = None
|
self._group_name = None
|
||||||
|
@ -660,10 +660,13 @@ class BluesoundPlayer(MediaPlayerEntity):
|
||||||
@property
|
@property
|
||||||
def is_volume_muted(self):
|
def is_volume_muted(self):
|
||||||
"""Boolean if volume is currently muted."""
|
"""Boolean if volume is currently muted."""
|
||||||
volume = self.volume_level
|
mute = self._status.get("mute")
|
||||||
if not volume:
|
if self.is_grouped:
|
||||||
return None
|
mute = self._sync_status.get("@mute")
|
||||||
return 0 <= volume < 0.001
|
|
||||||
|
if mute is not None:
|
||||||
|
mute = bool(int(mute))
|
||||||
|
return mute
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -1044,10 +1047,5 @@ class BluesoundPlayer(MediaPlayerEntity):
|
||||||
async def async_mute_volume(self, mute):
|
async def async_mute_volume(self, mute):
|
||||||
"""Send mute command to media player."""
|
"""Send mute command to media player."""
|
||||||
if mute:
|
if mute:
|
||||||
volume = self.volume_level
|
return await self.send_bluesound_command("Volume?mute=1")
|
||||||
if volume > 0:
|
return await self.send_bluesound_command("Volume?mute=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}"
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in New Issue