Playing a specific source / playlist / song on Sonos

if I remove that line (506) from code, on/off button and song selection button works.
but why doesn’t it work ? (volume)

Do me a favor and set your initial volume to something within the app…I am going to test it without which is the only way line 506 will fire. Standby…

set your initial volume to something within the app

what do you mean ? set initial volume in which app ? your app ?

Yes…in the second section down on the scenario where you choose your switches…Volume When Speaker Turned On

I will be curious if this works for you, but I just tested without anything outside of an Alexa Switch and the speaker and it works great…I assume this IS a Sonos and it works through the normal SmartThings control (i.e. it is integrated in completely? I can’t get mine to fail…

I would also recommend you are using all of the correct versions, and worst case, uninstall Alexa Helper and reinstall it and create a new speaker scenario.

well, it is a sonos but I use non-standard device type.
I use the media renderer device type from:

And I’ve tested volume with this device type . IT doesn’t work.
So it is a problem of Media Renderer device type.

I don’t know how to fix it though.

Ah…that explains it…BUT it should be fixed in your put in an initial volume into your app…right now if you don’t have that it polls the speaker and gets its volume and puts that into the dimmer…If you have a non standard device the ‘get level’ command may not work.

I understand that this should be fixed on the device handler I use.
(above - generic media renderer)

I hope the author helps me about this…

Yes…in theory…but it may not be as simple to poll the device.

Let me know if the author does not fix it…I think there is a way (with your help) that I can put in some code to at least check for your use case…in theory that command is optional and is only used to keep the virtual dimmer in sync.

actually the volume control on ST device does not work for me with this device handler.
I need a fix on the device handler in any case.

Ah…ok…let me noodle on this for a bit, but I think I know how I can gracefully trap this error and still allow you to ‘play’. Will PM you with a beta copy this week.

1 Like

thanks.
maybe you can also check the media renderer device handler :slight_smile:
I bet it is an easy fix for you if you could analyze the code.
I could not see any errors in the log (for media a renderer) so I am not able to move further.

Did you actually set the volume within the Alexa Helper scenario? I am curious if the ‘setLevel’ works at all with the media renderer.

yes it works that way.

Ok…I know of a way to error trap this then…stand by…

try this…this basically traps the setLevel command, and sends a note to the log if it can’t set the level…you MIGHT get an error at 530, but that is a good sign if you do…

Let me know how this works…this will give me the basic of making a change to the code that should allow for other speakers to be accommodated:

https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/Other-SmartApps/AlexaHelper/beta

so you just added this with a try_catch loop:

        if (speakerInitial){
        	def speakerLevel = speakerInitial as int
    		  try{
    		    vDimmerSpeaker.setLevel(speakerLevel)
    	    } 
    	    catch(e){
      	    log.debug "Can't set level...speaker will play at current level"    
      	  }
        }

I’ve installed this version but I can’t test it now. I will tell you tomorrow.
What shall I expect from this one ?

The expectation is that it will actually play something, or error out at line 530…but either way it will tell me that trapping the setlevel is the proper way to do this.

I don’t know what happened but now I am getting this error when turning on :slight_smile:

c8961620-eb45-4212-8cde-384fcb0cf970  07:43:23: info Alexa Helper scenario 'Test', 'Speaker on/off' triggered
b3e71620-0ce5-4200-aa1d-b44dc01be24c  07:43:22: info Alexa Switch sent 'Off' command
c8961620-eb45-4212-8cde-384fcb0cf970  07:43:17: error org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'null' with class 'null' to class 'int'. Try 'java.lang.Integer' instead @ line 511
c8961620-eb45-4212-8cde-384fcb0cf970  07:43:17: info Alexa Helper scenario 'Test', 'Speaker on/off' triggered
b3e71620-0ce5-4200-aa1d-b44dc01be24c  07:43:16: info Alexa Switch sent 'On' command

I actually transposed which command I was trapping…I fixed it…feel free to give it another shot (same code location).