Speak text and resume issues


#1

1) Give a description of the problem
Sonos speaker is supposed to speak text and then resume playing with all attributes. Instead no text is spoken and music stops completely until I restart in another way. Speaker is otherwise responsive and is online.

**4) Post a Green Snapshot of the piston

5) Attach any logs (From ST IDE and by turning logging level to Full)
(

PS > 183ms > PE > 33ms > CE
+243ms ║Runtime (47938 bytes) successfully initialized in 183ms (v0.3.108.20180906) (241ms)
+244ms ║╔Execution stage started
+245ms ║╚Execution stage complete. (1ms)
+247ms ╚Event processed successfully (247ms)
11/14/2018, 5:12:53 PM +716ms
+1ms ╔Received event [Front Door].contact = closed with a delay of 82ms
+236ms ║RunTime Analysis CS > 24ms > PS > 180ms > PE > 32ms > CE
+238ms ║Runtime (47929 bytes) successfully initialized in 180ms (v0.3.108.20180906) (236ms)
+239ms ║╔Execution stage started
+250ms ║║Comparison (enum) closed changes_to (string) open = false (1ms)
+251ms ║║Cancelling condition #2’s schedules…
+253ms ║║Condition #2 evaluated false (7ms)
+254ms ║║Cancelling condition #1’s schedules…
+255ms ║║Condition group #1 evaluated false (state changed) (10ms)
+258ms ║╚Execution stage complete. (19ms)
+259ms ╚Event processed successfully (259ms)
11/14/2018, 5:12:48 PM +62ms
+2ms ╔Received event [Front Door].contact = open with a delay of 95ms
+350ms ║RunTime Analysis CS > 39ms > PS > 249ms > PE > 61ms > CE
+354ms ║Runtime (47852 bytes) successfully initialized in 249ms (v0.3.108.20180906) (351ms)
+356ms ║╔Execution stage started
+373ms ║║Comparison (enum) open changes_to (string) open = true (2ms)
+377ms ║║Cancelling condition #2’s schedules…
+379ms ║║Condition #2 evaluated true (12ms)
+394ms ║║Comparison (string) :1c43b70f8d5602b05bed1415aaf20be3: is_not_any_of (string) :cd3ff539c8748ad65874b6fd2275eb5e:,:60af85880bc093aae351d828afad0f56:,:59f060ae8446d0ec5a590a5ccb5fc8cb:,:f2c7dc34829ffa4568c261029f01706d:,:7e9c2bdc95d864979ef530aa29a57fdb: = true (9ms)
+397ms ║║Condition #10 evaluated true (16ms)
+399ms ║║Cancelling condition #1’s schedules…
+401ms ║║Condition group #1 evaluated true (state changed) (35ms)
+405ms ║║Cancelling statement #3’s schedules…
+465ms ║║Executed virtual command [Living].saveStateGlobally (50ms)
+473ms ║║Executed virtual command [Living].wait (1ms)
+475ms ║║Waiting for 1000ms
+2188ms ║║Executed physical command [Living].playTextAndResume([Open, 75]) (702ms)
+2189ms ║║Executed [Living].playTextAndResume (706ms)
+2194ms ║║Executed virtual command [Living].wait (1ms)
+2196ms ║║Requesting a wake up for Wed, Nov 14 2018 @ 5:12:55 PM PST (in 5.0s)
+2202ms ║╚Execution stage complete. (1846ms)
+2204ms ║Setting up scheduled job for Wed, Nov 14 2018 @ 5:12:55 PM PST (in 4.993s)
+2219ms ╚Event processed successfully (2218ms)

**


#2

Honestly you’re not going to have much luck using the native Sonos functions in webcore. Especially if you’re like me and have multiple sonos speakers and multiple groups of speakers.
Sonos did recently open up their API, so hopefully things could change in the future and the functionality may be improved.

I use the following and it works perfect, even on grouped speakers:

It does require you to have another computer running and some ability to edit config files, etc… but once it’s set up, it works great.


#3

I use speak text and resume all the time successfully, but @allrak is right: it has its limitations not because of webCoRE, but due to limitations with either the Sonos API or the current DTH used by SmartThings.

A couple of things to be aware of: First and foremost, Speak Text and Resume will generally only work with Stations (Amazon, Pandora … I’m not certain about Spotify and a few others). It does not in any instance I’m currently aware of work with Playlists, sorry. Secondly, if you have one or more groups, you have to write your piston so that only the ‘group coordinators’ in each group receive the command.

There’s more, but for now I have two suggestions: (1) During testing, ensure that you are playing a Station. (2) Remove the Capture & Restore attributes lines as they serve no purpose here and in fact, overwrite what Speak & Resume is telling the speaker to do. It should work … most of the time.

Right now, the node.js alternative @allrak mentions is the only completely reliable alternative.


#4

As it happens I only ever listen to music through Pandora or Amazon music. And I’m not prepared to have another computer setup in my house exclusively for this purpose.

I just tries me crazy because it had been working fine for a couple months. Or every time the front door open and it would cause the Pandora station plays the words and then resume exact same Pandora station at the right level. And then it stopped working. I was using the capture app attributes to global store it was working fine. Now it says it can’t find the attributes.

Is there an alternative so that I can have it play at a certain level, then say text at a much louder level, and then go back to previous level and same station?


#5

Okay, you didn’t mention that it had been working fine or that you were trying to adjust volumes.

With regard to the first, I seem to recall one or two posts either here or elsewhere that mentioned it wasn’t working as well as it was before. I’ll have to do some more testing on my own system to see if I note any change.

As for the level,you can capture the and restore the level attributes the way you did originally, but don’t include all the other attributes. Most will have no affect upon restore, but a couple might contradict the resume command. I usually just capture the initial level in a variable, do a separate ‘set level’ command prior to the ‘speak text’ (setting this parameter in the command itself will cause speak test to fail), and then a second ‘set level’ command using the variable after a brief delay. That’s not necessarily a better way; it’s just the one I prefer. But I also use a separate piston that is called with argument for all Speak & Resume activity because I want to ensure that my Sonos group(s) get handled correctly.

Again, I’ll have to do some testing on this to see if anything has changed for me, but I’m on the run for a couple of days so it won’t happen right way.


#6

Last night I tested this over and over again until I got it to do exactly the right thing. Pause Sonos, play loud message, resume Sonos at previous level. And then I tested it a couple more times w/o changing a thing and it worked intermittently.

On the times it didn’t work, it paused Sonos, went up to the louder level, played a bit more of Sonos, paused, went back to previous vol level, and then continued to play without ever playing the text mp3.


#7

I am also very interested in this process as well. But I use playlists MOST of the time. I have been learning how to use JSON RPC with the Kodi API and I am hoping I can pause the current playlist, make the announcement through my speakers (not Sonos), and then resume the playlist.


#8

Is this still working for you?

Did you have to set any parameters to save the global values etc that not shown in the screen shot?

I’m trying out your code and using my own setup, sonos speaker and contact senor but it’s not fully working.
It’s speaking the text but not resuming the sonos playback.

Any idea’s?


#9

no other variables in this. The screenshot is the whole piston