[Deprecated] Sonos Speakers - Group Volume Adjustment via Voice Command


#1

As many Sonos owners are aware, the current integration between Sonos and Alexa does not yet provide a means of adjusting the volume of an entire group of speakers via voice command, instead restricting such adjustments to individual speakers or stereo pairs. (Sonos’ integration with Google is pending sometime this year, and it is as yet unknown if it will also omit that functionality).

This piston fills that gap, allowing the user to choose his or her preferred method (or methods) of initiating a volume adjustment. The simplest option is to use empty ST Routines, which can in turn be called by Alexa or Google Assistant. (Momentary switches could easily be used in lieu of routines). The second option uses Alexa/IFTTT integration to trigger the piston. The choice between these first two is simply a matter of preference in terms of language, either “run {routinename}” or “trigger {IFTTT applet}. Both will adjust the group volume up or down by a preset amount as defined by preference variables in the piston.

The third option, using Google/IFTTT, allows more granular control as Google’s IFTTT integration allows the user to specify the desired volume level in the voice command. So instead of just saying “volume up” or “volume down” you can say “change speaker volume to 40.” Another advantage of using this option is that Google is generally more flexible and natural in terms of its command language.

It is important to remember that when speakers are grouped, volume adjustments to speakers in the group are relative. What this means is that if the volume of the speaker that is controlling the group is 20, and you increase that by 10 to 30, you have increased the volume of that speaker by 50%. All other speakers in the group will also increase, not by an increment of 10, but by 50%. Thus, if one of the speakers in the group is at 60, it will increase to 90. The piston includes an option to limit such increases to avoid any unexpected surprises. (Decreases work similarly but for obvious reasons are generally less problematic).

As a general note, where Sonos speakers have been paired for stereo, only the left speaker of the pair needs to be defined in the device variable.

One final note, in its current iteration the piston assumes there is only one group among all the available speakers. Whether I’ll address that or not depends on how many more speakers I end up adding to my household before my wife seizes my credit card. :smirk:

I’ve included a snapshot of both the piston and the IFTTT applets below.

See also:
Sonos Speakers - Dashboard Tiles
Sonos Speakers - Auto Volume Adjustment


10-Day Weather Forecast Tiles
Sonos - Group Volume Control
#2

Love this! Thanks! Now I can say “Alexa turn the music down” and it will turn all my grouped speakers down. Or Up! Perfect!


#3

Hi @bthrock,

I see that you got some nice automation pistons created, I was wondering if maybe you could guide me in the right direction as I’m not 100% sure how to approach what I want to accomplish.

I got the SWIPE controller (fibaro) it is visible as a button controller in smart things, it takes swipe up down left right gestures but also has clockwise and conterclockwise circe gestures, which translates to button being held.

I was thinking if it would be possible to write piston that would translate this to volume up/down command as long as the button is held (I keep spinning the hand).

Something like maybe increase by 5 every second as long as the button is pressed?

Would you be able to help with this?

Dex


#4

Not being familiar with the SWIPE controller, I would have to guess based on your description. Perhaps someone more familiar with the device can jump in here.

Also note that since my original post Sonos has added IFTTT integration, so group volume can be adjusted via an IFTTT action. That would lead me to my first question, which is whether it might be possible to use the Fibaro and Sonos IFTTT integration directly, without involving SmartThings at all. I don’t know the answer to that.

If not, then its a little more complicated. I assume that as long you ‘hold’ the button it maintains a particular state? If so, then the initial trigger for your piston would be state change on that switch, with subsequent checks ever second to see of the button is still in that state. Something roughly along the lines of

on event [device : switch]
while switch is on
raise volume 5% (using IFTTT or modifying my original piston)
wait 1 second
end while

Again, I’m just brainstorming and could be way off here. With that in mind, I’d probably work with the above all by itself, substituting ‘log info to console’ for ’ raise volume’ just to ensure you’ve got that element working first. Once you’re satisfied it should be easy enough to modify your piston to use IFTT or the code I created above. I can jump back in at that point if needed.


#5

@bthrock, THANKS for sharing this piston! I’ve got a few questions I’m hoping you’ll assist with:

  • If I’m an Alexa user and wouldn’t want to say “trigger”, I would want to use the “empty ST Routines” method- is that correct? How… Do you have an example of that? (I guess as an alternative, I could use the IFTTT method and then get around saying “trigger” by setting up an Alexa Routine to run the IFTTT applet).

  • I’m assuming this can control only one group of sonos - correct? I have 8 Play:Ones but I’m thinking that in the piston I should only designate the 4 that I generally use in a group.

  • If using IFTTT, I’d need to have the applet you showed screenshot of, plus another for VolumeDown, correct?

Thanks so much!!


#6

@merrick777,

  • Alexa has evolved since this was posted and with ST moving away from routines, I would recommend invoking the piston via an Alexa Routine that turns on a virtual momentary switch in Smarthings.
  • As written, yes, this only controls one group. The piston was intended primarily to provide a basic example others could build on if needed. I never developed it further as I use a node.js server on a raspberry pi that provides me with a lot more flexibility with grouping, volume control and more.
  • Using the Alexa Routine / Virtual Momentary Switch, you can avoid IFTTT altogether, which for me is generally preferable anyway.

Hope this helps.


#7

@bthrock, VERY helpful… thanks! I created UP and DOWN momentary switches, and created Alexa routine to turn on the momentary switch. Now I need to edit your piston’s IF statements to proceed if the momentary switch state changes… is that correct? Would this work… and if so, do I just make it 1 second?


#8

Under “What kind of comparision?” I would use “changes to” and then “on.” You’re using “changed,” which is a condition rather than a trigger and may not run at all. Also, using “on” prevents your piston from running a second time when the momentary switch turns itself off.


#9

@bthrock, thanks again- this is fantastic! Now I just have to find a way around the “ducking”. When I tell alexa to raise or lower the volume, it does it, but then it goes even further about 5 seconds later… that’s annoying.


#10

Not clear on exactly what you are experiencing, however, do you have Follow-Up Mode enabled on your Sonos Ones?


#11

I think the new sonos integration has broken this piston. It isn’t working for me now. Is there something that we need to change in the piston to get it working?


#12

Unfortunately, I haven’t tested the new integration with any of my devices or pistons, but I wouldn’t be the least bit surprised if something is broken. I will try to take a look at this soon and hopefully before the old integration is deprecated, which as I understand it is currently scheduled to happen on October 17th.


#13

Took a quick glance and can see there are a number of changes to be made, especially with regard to working with groups. It won’t be quick, but it should be doable.


#14

It seems that once you update the speakers to the webhook device driver, it breaks the piston. I will look forward to your corrections. I have had this working great since you did it originally. It is the only piston that I still run since moving to HE.


#15

Did you get a chance to look at this yet?


#16

Yes, getting close … just trying to track down some occasional misbehavior before I post anything.


#17

With the changes to the Sonos integration within SmartThings, this piston has been deprecated in favor of the one below.