Add mute_toggle to roon volume events (#114171)

Add mute_toggle event.
This commit is contained in:
Greg Dowling 2024-06-07 11:25:14 +01:00 committed by GitHub
parent a8becb1248
commit 92ed20ffbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 8 deletions

View File

@ -47,7 +47,7 @@ class RoonEventEntity(EventEntity):
"""Representation of a Roon Event entity.""" """Representation of a Roon Event entity."""
_attr_device_class = EventDeviceClass.BUTTON _attr_device_class = EventDeviceClass.BUTTON
_attr_event_types = ["volume_up", "volume_down"] _attr_event_types = ["volume_up", "volume_down", "mute_toggle"]
_attr_translation_key = "volume" _attr_translation_key = "volume"
def __init__(self, server, player_data): def __init__(self, server, player_data):
@ -77,15 +77,17 @@ class RoonEventEntity(EventEntity):
) -> None: ) -> None:
"""Callbacks from the roon api with volume request.""" """Callbacks from the roon api with volume request."""
if event != "set_volume": if event == "set_mute":
event = "mute_toggle"
elif event == "set_volume":
if value > 0:
event = "volume_up"
else:
event = "volume_down"
else:
_LOGGER.debug("Received unsupported roon volume event %s", event) _LOGGER.debug("Received unsupported roon volume event %s", event)
return return
if value > 0:
event = "volume_up"
else:
event = "volume_down"
self._trigger_event(event) self._trigger_event(event)
self.schedule_update_ha_state() self.schedule_update_ha_state()

View File

@ -29,7 +29,8 @@
"event_type": { "event_type": {
"state": { "state": {
"volume_up": "Volume up", "volume_up": "Volume up",
"volume_down": "Volume down" "volume_down": "Volume down",
"mute_toggle": "Mute toggle"
} }
} }
} }