Hi everyone, I’m looking for some advice/ideas on how I go about making improvements to my current announcements.

I have a number of Sonos speakers around my home and mainly use the one in the Kitchen to make the announcements, such as weather and travel time. At the moment I have a basic setup in place when tells me the same thing every morning. At the moment my morning announcement goes like this; “Good Morning, the current weather condition is clear and there is a high of 5 degrees.” I also add on my estimated travel time to work, if I’m going by car.

The idea I have is to setup a number of different announcements such as;
“Good Morning, your estimated travel time to work is 40 minutes. Today’s weather has a high of 10 degrees and clouds.”
or
“Good Morning, there is a low of -1 degrees expected today. Wrap up warm. The expected time to work is 42 minutes.”
or
"Hello, it’s likely to be warm today as the high is expected to reach 22 degrees. Your travel time to work appears to be extended as is 55 minutes.

I know how to separate the various components of my announcement, just not how to create a rule that it’s a million lines long. So I’m looking for any help/advice or ideas from other users out there how have something similar in place.

1 Like

Create 3 or 4 patterns for an announcement and then
do a rolling choice in the rule:

``````var counter = 0

rule "morning announcement"
when (trigger)
then
counter++
if (counter == 1) say(pattern1)
if (counter == 2) say(pattern2)
if (counter == 3) {
say(pattern3)
counter = 0
}
end
``````

Now, counter will not persist between restart of OH so you may want to use a proxy item for that instead