Can SONOS volume be configured with an Automation Rule

Hi,

I have created a group of two SONOS speakers and use that group for a daily alarm. The constraint with the SONOS app is that there is no ability to set the volume level per speaker. Consequently, one speaker is either too loud or one is too faint.

My thinking was to use a scheduled automation to “reset” the speaker volume that is too low but I am open to any recommendations. I looked at the automation options for the SONOS device and there doesn’t seem to be any way to adjust the volume.

Any help and guidance would be greatly appreciated.

Yes.

Albeit a schedule is not how I would approach it. It would work if that is what fits you best.

I personally trigger on a players volume change;

platform: state
entity_id: media_player.tv_sonos
attribute: volume_level

As for the action, use the media_player service;

service: media_player.volume_set
data_template:
  entity_id: media_player.kitchen_sonos
  volume_level: |-
    {{ (states.media_player.tv_sonos.attributes.volume_level | float(default=0)
      * (states('input_number.kitchen_sonos_percent')|float(default=0) /100) ) | round(2)
    }}

As you can see, I use an input_number using a percentage/ratio.

2 Likes

When I join multiple Sonos devices together into a Sonos group, I can set the volume of each device within the Sonos group independently using media_player.volume_set.

To be clear, a Sonos group is not the same as a Home Assistant media_player group.

1 Like

Firstly, thank you for the reply. I am very new to Home Assistant and am using the web interface to configure the automation and there is no volume option. Are you bypassing that and using YAML directly?

Yeah click the little three dots in the upper-right of the action and select “Edit in YAML”. Be aware you will need to edit the entity names to match yours.

The media_player.volume_set service call is, in fact, available in the web interface of the Automation Editor.

1 Like

I have learned something new. Thank you!

The Sonos app definitely allows setting each speaker’s volume level.

Yes, that’s true but I don’t see that function when setting an alarm.