Okay here is the stuff from my announce rules in 4.1. I am basically mimicking the functionality of some available User-defined apps that I used to use when I first started with Habitat. Since they never really did what I needed exactly, I decided to write my own rules, which work pretty well. Like many of us, I make minor changes over time as I have new ideas. This is basically a way to send announcements around the house for various reasons, with a variety of triggers.
btw, I use prefixes for my variables: GBL = Global, LCL = Local.
#1) I have a rule that sets up my global variables, which include an AnnounceMessage, AnnounceSound (Sound file to play before the TTS), and AnnounceSpeaker (numbered Google Nest Minis around the house). These are the rules I am constantly writing and changing.
#2) That first rule then triggers another the master announce rule, which uses the AnnounceSpeaker variable to figure out where to send the message. This is a repetitive code that looks like this:
Master PlayTrack Code
IF (Variable AnnounceSpeakerA(1) = 1(T) [TRUE]) THEN
Run Actions: * PlayTrack-01-Kitchen
END-IF
IF (Variable AnnounceSpeakerA(1) = 2(F) [FALSE]) THEN
Run Actions: * PlayTrack-02-LivingRoom
END-IF
IF (Variable AnnounceSpeakerA(1) = 3(F) [FALSE]) THEN
Run Actions: * PlayTrack-03-Downstairs
END-IF
IF (Variable AnnounceSpeakerA(1) = 4(F) [FALSE]) THEN
Run Actions: * PlayTrack-04-Master
END-IF
IF (Variable AnnounceSpeakerA(1) = 5(F) [FALSE]) THEN
Run Actions: * PlayTrack-05-Chloe
END-IF
IF (Variable AnnounceSpeakerA(1) = 6(F) [FALSE]) THEN
Run Actions: * PlayTrack-06-Cian
END-IF
#3) Using the above code, the appropriate child rule is played, which plays the selected sound, waits a designated time for that sound, then plays the TTS to the designated speaker. I basically have multiple copies of this rule for each speaker. See below:
PlayTrack-04 Mom Speaker Code
Set LCL-RestoreVol to Mom speaker volume
Set Volume on Mom speaker to 50
IF (Variable AnnounceSound(0) = 1(F) [FALSE]) THEN
playTrack('GBL-SND-01(http://192.168.86.230/local/Relax_BeautyBells.mp3)') on Mom speaker
Delay GBL-SndTime-01(2) seconds
END-IF
IF (Variable AnnounceSound(0) = 2(F) [FALSE]) THEN
playTrack('GBL-SND-02(http://192.168.86.230/local/smb_Pause.mp3)') on Mom speaker
Delay GBL-SndTime-02(2) seconds
END-IF
IF (Variable AnnounceSound(0) = 3(F) [FALSE]) THEN
playTrack('GBL-SND-03(http://192.168.86.230/local/smb_Coin.mp3)') on Mom speaker
Delay GBL-SndTime-03(2) seconds
END-IF
IF (Variable AnnounceSound(0) = 4(F) [FALSE]) THEN
playTrack('GBL-SND-04(http://192.168.86.230/local/smb_Powerup.mp3)') on Mom speaker
Delay GBL-SndTime-04(2) seconds
END-IF
IF (Variable AnnounceSound(0) = 5(F) [FALSE]) THEN
playTrack('GBL-SND-05(http://192.168.86.230/local/smb_Kick.mp3)') on Mom speaker
Delay GBL-SndTime-05(2) seconds
END-IF
IF (Variable AnnounceSound(0) = 6(F) [FALSE]) THEN
playTrack('GBL-SND-06(http://192.168.86.230/local/Relax_Varimba.mp3)') on Mom speaker
Delay GBL-SndTime-06(3) seconds
END-IF
IF (Variable AnnounceSound(0) = 7(F) [FALSE]) THEN
playTrack('GBL-SND-07(http://192.168.86.230/local/Relax_WaterMusic.mp3)') on Mom speaker
Delay GBL-SndTime-07(4) seconds
END-IF
IF (Variable AnnounceSound(0) = 8(F) [FALSE]) THEN
playTrack('GBL-SND-08(āā)') on Mom speaker
Delay GBL-SndTime-08(0) seconds
END-IF
IF (Variable AnnounceSound(0) = 9(F) [FALSE]) THEN
playTrack('GBL-SND-09(āā)') on Mom speaker
Delay GBL-SndTime-09(0) seconds
END-IF
IF (Variable AnnounceSound(0) = 10(F) [FALSE]) THEN
playTrack('GBL-SND-10(āā)') on Mom speaker
Delay GBL-SndTime-10(0) seconds
END-IF
Speak on Mom speaker: '%AnnounceMessage%'
Delay 0:00:15
Set Volume on Mom speaker to LCL-RestoreVol(40)
What would be awesome, is if I had something like array variables to load with the sound file address, and maybe even array variables to load the speaker locations, I could have the code auto grab the appropriate data from the original variables in the first rule, and not have to copy the same code over and over again for multiple sound files and multiple speakers.
Once again, my current (copied a lot) system does work. Just looking to streamline. I may dive into Groovy more as well, I'm just not at that point yet. However, I thought the habitat hive mind might have some ideas, and as always, you all do! Thank you!