webCore - Randomize announcements?

When you have this working would you mind posting so people (me :wink:) can import and use?
I have something in mind and this could be useful.
Thanks.

1 Like

Well, not having much luck with this. It seems to run (see logs below) but I don’t hear anything. Any NEW pistons that I try to setup with Speak, nothing comes out of the Sonos. If I run an old (unmodified) piston with speech, it plays out of the Sonos. Wierd.

New Test Piston:


Old Piston that works fine (only modified the time so it would run):


Could someone try to setup a brand new piston with speech and see if it works for them? Just want to see if it’s just my system or not.

Thanks!

I tried your piston using speak text and it does not work for me either.
If I change to speak text and resume, it does work.
Could you use this instead?

I was requested to add volume to all three commands - that explains the old vs new pistons - if you edit an old one, it will stop working too. Looks like Sonos does not accept a volume parameter for playText? Any errors in the IDE, for either webCoRE or the Sonos player? The Audio Notification capability has been modified over and over again by ST, it looks like the implementation of Sonos no longer matches the documentation :smiley:

@SBDOBRESCU

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

I think it still does…

New Piston cannot have “null” volume …

Old Piston works because the volume is not defined

If you go in the new piston and set a volume, your piston should work fine

UPDATE!!!


@ady624 is correct! The playText() command NO LONGER takes the optional NUMBER level argument as noted in the Documentation. Only playTextAndResume() and playTextAndRestore() …

@Jim ?!?


Should the ‘optional’ be removed then??

Thanks for working on this guys. Thought I was going nuts there for a little bit. Using “speak text and resume” works great. Now to go through all my speech pistons and randomize everything! Got to keep the family on their toes.

Thanks again.

1 Like

@Jim any input please? Should playText have a volume parameter (like documentation suggests) or not (like Sonos is implemented)?

Thank you

Here is how I do random text. I have a bit more extensive one in CoRE that I haven’t brought over yet but it’s the same idea. Use a switch block with a random variable to select the different cases at random

That is old school. Check out the random() function above

Here a working example of the new Randomize. Hope this helps.

The piston:

An exploded view of the speech:

1 Like

Which capability are we referring to? Audio Notification supports the playText() command, which takes a required string message, and an optional Number volume argument. But I’m not seeing Sonos implement that capability.

Look at the error in this post. The optional number for volume doesn’t appear to be valid. Or am I interpreting the error wrong?

playText(string) …

The Sonos handler has the following capabilities:

[on, off, refresh, play, pause, stop, nextTrack, playTrack, setLevel, mute, previousTrack, unmute, setTrack, resumeTrack, restoreTrack, ping, playText, playTextAndResume, playTextAndRestore, playTrack, playTrackAndResume, playTrackAndRestore, subscribe, getVolume, getCurrentMedia, getCurrentStatus, seek, unsubscribe, setLocalLevel, tileSetLevel, playTrackAtVolume, playTrackAndResume, playTextAndResume, playTrackAndRestore, playTextAndRestore, playSoundAndTrack]

If playText is used, produces this error …

Yes, since the volume level argument isn’t required, it can’t be assumed it will be implemented. As you’ve found, looks like Sonos does not implement the command to accept the volume parameter.

I am mistaken - I was looking at the old, pre-super connect device handler for Sonos. The current (and super lan connect enabled) Sonos device does implement the Audio Notification capability. My bad!

1 Like

Thanks for the quick reply…

Ok, so then why does playText throws the error when used with volume?

The Sonos does not accept the volume parameter for the playText() command. The Audio Notification capability specifies the String message parameter as required, but not the volume parameter. So the Sonos command signature is def playText(String msg) which is why the error is thrown.

1 Like

But @Jim, hold on a second. Since we’re talking about required vs optional, the “optional” attribute of a parameter does not imply it’s requirement to not be there. Optional means it can be provided or not. Nothing in the documentation suggests that some DTHs may accept it, some may not. Being optional releases the caller from the burden of sending that parameter, but not the callee from the requirement to accept it. The DTH should accept it and ignore it, rather than not accept it. That’s how it work with all programming languages I know. Does that make sense?

1 Like