I just got a Sonos Play1 and I’ve been playing around with old rules I had to get the results of the rule to be spoken. The only problem I have if the words are just a list of items from a group filter rule they are read one after another with out a pause. Is there a way to put a pause in between them to understand them better? Here is a sample rule I was working on:
rule "Entrance Door left open warning"
when
Item SecurityTimer received command OFF
then
val entrancedoor = GEntranceDoors.allMembers.filter([s | s.state == OPEN]).sortBy([lastUpdate]).map[name].join
val audiomessage = "Security Alert:The following entrance doors have been open for an hour:" + entrancedoor
Speech_Out.sendCommand(audiomessage)
Thread::sleep(5000) // 5 seconds
say(Speech_Out.state.toString)
SecurityTimer.sendCommand(ON)
end
Are you putting a space between the names? You can do that with a reduce
sortBy[lastUpdate].map[name].reduce[list, name | list + " " + name]
NOTE: I’m just typing that in, I may have something wonky in the reduce.
That should put a natural pause (i.e. the type of pause say already puts between words). I don’t know much about say, but using ", " might add a longer pause, or perhaps " " (two spaces).
If I remember correctly, your biggest challenge will be that say returns immediately and doesn’t block until it is done saying what you told it to say. Consequently, it will be very difficult to insert a Thread::sleep between calls to say to add the pause because you will have to predict how long it takes to say something which can change as the names of your Items change from one to the next. Otherwise, there will be inconsistent pauses between the names or even worse, cases where two Items are said on top of eachother.