Sonos triggers?

I’m a newbee. Just installed Home Assistant on a Raspberry and everything seems to be working fine. I have multiple integrations up and running and are playing with automation.

My question is simple: How can i get a trigger to fire when e.g. volume on my sonos is turned up/down. - of basically any action is taken on sonos (e.g. play started or stopped)

I can’t find anything on sonos triggers except on alarms. Not anything on “normal operation”, “Current status” or the like…

Thomas

I look at entities, instead.

Each speaker entity has a state of playing/paused/etc.

Those entities have attributes of volume level, media details, etc.

Have a look at the developer tools states tab.

You can pick these up with State triggers, in automations.

Hi Luke,

Thanks a lot. That was exactly what I was looking for.

However, now I’m faced with a new challenge. When volume changes (trigger), I want to call a service with the volume as a parameter to that service call.

Can you point me in the right direction on how to “pick up” the volume from the state-change and feed it as a parameter to the service call?

Thomas

Hi Thomas,
As a preface, there are many ways to do things with Home Assistant. I’m still learning.

You could do this with a little YAML inside your automation. The automation can still be edited in the GUI, my example looks like this.

The YAML is interpreted when the automation executes, you can see this in the trace:

There are other ways to achieve this.

  • You could create a new sensor from the volume attribute, do this with a ‘template sensor’ - an entry in your configuration file.
  • You could store the volume attribute in a number helper.