I am trying organise my different Chromecast devices so that I can direct the SAY command to the appropriate Google Home Mini speaker without having to type the device ID
I have assigned and populated strings to hold the following
1. **Message** = "Hello, how are you today?"
2. **Voice** = "voicerss:enUS"
3. **Lounge_Chromecast_ID** = "chromecast:chromecast:123456789"
The syntax is SAY (Object text, String voice, String sink)
E.g. say(“Hello world!”, “voicerss:enUS”, “sonos:PLAY5:kitchen”)
It works fine if I use:
say(message.state.toString, voice.state.toString, “chromecast:chromecast:123456789”)
It does not work when I do:
say(message.state.toString, voice.state.toString, Lounge_Chromecast_ID.state.toString)
What is it about the final part of the SAY command that I am getting wrong?
Once I converted the item to a variable before using in my other .rules I was able to play the speech file
var String AudioSink
AudioSink = Lounge_AudioSink.state.toString
var String Voice
Voice = Lounge_Voice.state.toString
var String Message
Message = "Wake up you awesome individual!"
say (Message, Voice, AudioSink )
All this just to give the kids the ability to chose the voice they want for their rooms!
I am using a a simple string item which is holding human (child) readable names which can be switched on a sitemap. In the rule I use a switch case like:
switch (selectedSpeaker) {
case "Kueche":
AudioSink = "sonos:PLAY1:RINCON_B8E937E0C16201400";
break;
case "Wohnzimmer":
AudioSink = "sonos:PLAY1:RINCON_B8E937BDEF0E01400";
break;
case "Buero":
AudioSink = "sonos:PLAY1:RINCON_949F3E7D2EF401400";
break;
case "Gaestezimmer":
AudioSink = "sonos:PLAY1:RINCON_B8E937E0C14201400";
break;
default:
AudioSink = "sonos:PLAY1:RINCON_B8E937BDEF0E01400";
}
That way the unreadable part is hardcoded in the rule only.