[OBSOLETE] Simpe Volume with Voice

Hi. Any way to integrate the phrase “Turn it down on Sonos” instead of setting a specific volume?

The idea being it would turn it down by a default value.

I am still pretty new to ST, and I am trying to use my hub to limit the maximum volume via CoRE and the Sonos Bridge Dimmer outlined in this post. I have successfully set it up so that if the volume is adjusted with the virtual dimmer, it reverts back to it’s set level. However, if the speaker volume is set in the app or on the speaker itself (or on the SONOS title on actiontiles), it is unlimited. Does anyone know how I can get the virtual dimmer to update it’s volume with the volume on the actual device?

Hi @Rancod99 – From what I understand, the Alexa-Sonos integration allows you to use the phrase "Turn down the " in order to adjust dimmer device types. So if you named your Sonos something like “Kitchen Stereo”, then the phrase “Turn down the Kitchen Sonos” should bring the volume down by around 10 or 25 % (I forget exactly what the number is). I personally find this command too coarse, so I often instead refer to specific values in voice-commands like “Alexa, set TV Sonos to 25” or “Alexa, set TV Sonos to 30”. My wife seems to have adapted to the voice functionality quite nicely, but personally, I use the volume rocker on my phone to make fine adjustments when we’re watching a movie and we don’t want to wake up our kid. More specifically, to your question, there is a default value that’s implemented when you simply say “turn down…”, but I don’t think you can pre-set the default step-size. As a result, it may work for your use-case, or it may not.

And Hi to you too @mikedebski! Short version – I believe it is possible to have the feedback you’re looking for, however I don’t think it would be the instantaneous feedback that would provide the desired functionality.

Longer version – if you look in the documentation there’s a section for music players specifically tailored for Sonos functionality:

http://docs.smartthings.com/en/latest/capabilities-reference.html#musicplayer

In the attributes section there is a status string that can be retrieved from the Sonos. I believe the status string should provide the volume level, and you can imagine an app that polls the Sonos’ volume level on a regular basis to check whether it’s above a certain level. The problem is that this app would have to poll on a regular interval, which if you read about scheduling commands in the ST documentation is somewhat cumbersome to do in real-time. What you want is a command that notifies you when the volume is adjusted so you can run a check on whether the volume has exceeded a threshold value. As-of-yet, Sonos has not provided that in their API and as a consequence, it’s a limit to what you can do within ST.

My biggest disappointment is that I released this app around the time Sonos announced Alexa-Sonos integration and they promised it around 4th quarter of 2016 or 1st quarter of 2017. Well, we’re now around the beginning of 3rd quarter in 2017 and as a member of the Sonos Beta Tester Community, I can say I haven’t had a chance to test it out yet (although that doesn’t mean other beta testers haven’t been testing it). I guess Sonos has a reputation for slowly and deliberately releasing products that are fully-market-ready – I take their delay to mean that they are making sure Alexa-Sonos will be 100% when it’s released. Nevertheless, the “Simple Volume with Voice” app here intended to be a short-term solution until the official integration was released.

No sooner do I open my mouth, and then this:

Thanks for the app and reply. I was a beta tester on the Sonos/Echo integration. Half way through the beta, they decided to drop support for controlling all speakers; hence I can no longer control ( via voice ) the volume of all my 3 Sonos speakers. This is where your app came in handy.

@Rancod99 I hope it helps! Having spent time yesterday setting-up and playing with the Alexa/Sonos integration now that it’s open Beta, I’m a bit underwhelmed. It seems (1) there’s confusion with my ST devices with highly similar names (e.g., Living Room is the room for a speaker, but it’s also the name of a group of lights), and (2) functionality with the PlayBar isn’t as advanced as the Play:3’s. I’ll give it a week or two to see what use-cases it’s helpful for, and which it’s unnecessary.

As a foot note, I’m constantly surprised by my “lived experience” in discovering the differences between “cool” and “useful.” If asked to predict whether a new device/app/whatever is “cool” or “useful”, I’d probably be wrong 9 out of 10 times. Seriously, a coin-toss would be more accurate in the long-run…

I know it’s been over 2 years, but I just updated Sonos to the new device type and broke this app. In the interest of completeness, here’s the revised code:

/**

  • Dimmer-Sonos Bridge
  • Copyright 2016 Jesse Silverberg
  • Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except
  • in compliance with the License. You may obtain a copy of the License at:
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  • on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  • for the specific language governing permissions and limitations under the License.

*/
definition(
name: “Dimmer-Sonos Bridge”,
namespace: “JLS”,
author: “Jesse Silverberg”,
description: “Bridge a virtual dimmer to a Sonos for Alexa volume control.”,
category: “Convenience”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”)

preferences {
section(“Bridge this dimmer…”) {
input “myDimmer”, “capability.switchLevel”, multiple: false, title: “Choose virtual dimmer”, required: true
}
section("…to this speaker") {
input “mySpeaker”, “capability.mediaPlayback”, title: “Choose Speaker(s)”, multiple: true, required: true
}
}

def installed() {
log.debug “Installed with settings: ${settings}”
subscribe(myDimmer, “level”, setNewVolume)
}

def updated() {
log.debug “Updated with settings: ${settings}”
unsubscribe()
subscribe(myDimmer, “level”, setNewVolume)

}

def setNewVolume(evt) {

log.debug "in handler with: ${evt.value}"
def newVolume = myDimmer.currentState("level").integerValue
mySpeaker.setVolume(newVolume)

}