Skip to content

Commit

Permalink
Add mute_toggle to roon volume events (#114171)
Browse files Browse the repository at this point in the history
Add mute_toggle event.
  • Loading branch information
pavoni authored Jun 7, 2024
1 parent a8becb1 commit 92ed20f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions homeassistant/components/roon/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RoonEventEntity(EventEntity):
"""Representation of a Roon Event entity."""

_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"

def __init__(self, server, player_data):
Expand Down Expand Up @@ -77,15 +77,17 @@ def _roonapi_volume_callback(
) -> None:
"""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)
return

if value > 0:
event = "volume_up"
else:
event = "volume_down"

self._trigger_event(event)
self.schedule_update_ha_state()

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/roon/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"event_type": {
"state": {
"volume_up": "Volume up",
"volume_down": "Volume down"
"volume_down": "Volume down",
"mute_toggle": "Mute toggle"
}
}
}
Expand Down

0 comments on commit 92ed20f

Please sign in to comment.