Announcement

Collapse
No announcement yet.

Dynamically change GH TTS target groups - how are you doing it?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Dynamically change GH TTS target groups - how are you doing it?

    I would like to have certain TTS notifications sent to 1 of 3 different GH/chromecast speaker groups depending on occupancy conditions (handled separately by various means). E.g., send only to downstairs speakers when someone may be sleeping upstairs, include outside speakers when we're working in the yard, etc. One way would be triplicate notification events with each conditioned on one of the 3 occupancy conditions, but hopefully there's a more efficient way.

    I also played with muting certain GH/chromecast devices depending on the situation, but when they're used for other purposes muting is problematic.

    Anyone doing this? Ideas of how to efficiently handle it?

    Thanks.
    -Wade

    #2
    I've started to migrate all of my TTS to go through a script. This script can send audio to the speakers as well. I have a condition in there to only do something if somebody is home...aside from the dog. The dog hates the voices lol It will also show the text of the TTS on my TV, if it is on. With this script method you could apply additional logic to determine which speaker or speaker group to target. It also makes future changes to this logic much easier to have it centralized in a script vs in every event.

    Here's what I've started with. Parameters separated with a pipe | and if it has ".wav" it attempts to play that sound file, otherwise it speaks the text. Send as many parameters as you want.

    Example Parameters strings:

    weather-warning.wav|A severe thunderstorm warning has been issued.|weather-warning.wav
    airport-bingbong.wav|Your attention please. I have something important to say.

    Note: the .wav files must exist on your system in the proper place

    Code:
    Sub Main(Params As String)
    
     ' soundFile|speakText
     Dim ParamsArr() As String
     ParamsArr = Params.Split("|")
    
     ' check Home Occupancy status
     Dim homeOccupancy = hs.DeviceValue(###)
     'hs.WriteLog("SpeakWithSound", "homeOccupancy: " & homeOccupancy)
    
     If homeOccupancy > 10 Then
    
      Dim lg55Status = hs.DeviceValue(###)
    
      For Each param As String In ParamsArr
       If InStr(1, param, ".wav", vbTextCompare) > 0 Then
        hs.PlayWavFile("C:\Program Files (x86)\HomeSeer HS3\Media\" & param, "", true)
        hs.WriteLog("SpeakWithSound", "Playing: " & param)
       Else
        If lg55Status = 202 Then
          ' This actually shows a toast message on the screen, not TTS audio
          hs.Speak(param, false, "$MC$TVName Remote$:*")
        End If  
        hs.Speak(param, true)
        hs.WriteLog("SpeakWithSound", "Speaking: " & param)
       End If
       hs.WaitEvents()
       hs.WaitSecs(1)  
      Next
    
     Else
    
      hs.WriteLog("SpeakWithSound", "Skipped due to no occupancy.  homeOccupancy: " & homeOccupancy)
    
     End If
    
    End Sub
    HomeSeer 3, Insteon, Z-wave, USB-UIRT, Google Hub/Chromecasts/Smart Speakers, Foscam cameras, Amcrest camera, RCA HSDB2a doorbell
    Plugins: BLLAN, BLOccupied, BLUSBUIRT, Chromecast, Insteon, Jon00 Homeseer/Echo Skill Helper, Jon00 DB Charting, MediaController, NetCAM, PHLocation2, Pushover 3P, weatherXML, Z-wave

    Comment


      #3
      spud I apologize if I've asked previously. Can't find the post if I have.

      Would you consider making the TTS enable/disable parameter controllable via event and/or immediate script?

      Click image for larger version

Name:	Annotation 2019-12-24 121420.jpg
Views:	47
Size:	14.6 KB
ID:	1349469
      Thanks.
      -Wade

      Comment

      Working...
      X