Announcement

Collapse
No announcement yet.

Replacing hs.Speak in vb script

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

  • Replacing hs.Speak in vb script

    I have several scripts where I use HS.Speak, what would the best way be to use my chromecast group announcements?

    I have 6 speakers and currently I get something like 3 of the connect sounds before it speaks.

    And since this script speaks several times, each speak gives the connect sound 3 times, speak, connect sound 3 times, speaks, connect sound 3 times, speaks.

    And as if that is not bad enough, all of the speakers do it at different times, so the house is completely out of sync! ;-)

    Any help would be appreciated


    Sub Main(parm as object)
    hs.Speak("Good evening")
    '*************** query if tomorrow is thursday for garbage day ******
    Dim tomorrow As Integer = DateTime.Now.DayOfWeek +1
    if tomorrow = 4 then
    hs.Speak("Tomorrow is garbage day. Please do not forget to put the garbage can out tonight")
    end if

    ' ************** query if this week is a recycling week **********
    Dim WeekNumber As Integer = DatePart(DateInterval.WeekOfYear, Date.Today)
    if WeekNumber Mod 2 <> 0 then 'take the week number and divide it by mod (2) if it is even the remainder will be 0. <> is not equal
    if tomorrow = 5 then
    hs.Speak("Tomorrow is recycling day. Please do not forget to put the recyclables out tonight")
    end if
    end if

    '************** Weather **************
    ' ************** prepare for tomorrow **********
    if hs.deviceValueEx(713) > 75
    hs.Speak("it is going to rain tomorrow. Do not forget your umbrella.")
    else if hs.deviceValueEx(713) > 30
    hs.Speak("it may rain tomorrow. Bring your umbrella.")
    end if

    if hs.deviceValueEx(726) > 80
    hs.Speak("its going to be hot tomorrow!")
    else if hs.deviceValueEx(726) > 70
    hs.Speak("it is going to be nice tomorrow! No jacket required")
    else if hs.deviceValueEx(726) > 60
    hs.Speak("it is going to be cool tomorrow! You may want a jacket")
    else if hs.deviceValueEx(726) > 32
    hs.Speak("it is going to be cold tomorrow! Do not forget your jacket!")
    else if hs.deviceValueEx(726) > 0
    hs.Speak("it is going to be wicked cold tomorrow!")
    end if
    '************** Tonights weather forecast **********
    hs.Speak("Tonights forecast ")
    hs.Speak(hs.deviceString(720))

    '************** Tomorrows weather forecast **********
    hs.Speak("Tomorrows forecast ")
    hs.Speak("Tomorrows high is " & hs.deviceValueEx(726) & " degrees")
    hs.Speak("with a low of " & hs.deviceValueEx(727) & " degrees")
    hs.Speak("Chance of rain is " & hs.deviceValueEx(713) & " percent")

    hs.Speak("I hope that you have a good nights sleep")

    hs.Speak("Good night")

    End Sub

  • #2
    Why not build one long string and then speak that instead of speaking each segment individually?

    Comment


    • #3
      Yes, creating a long string is possible. But how would I speak it in the script?

      Comment


      • #4
        Also, while looking at the log, I see why i get so many connection beeps. I have a couple of groups, and it looks like it connects to the groups AND the speakers individually. SO if a speaker is in every group, it will get the connect tone for that group, and the next group, and the next group then for that speaker.

        Feb-24 17:39:39 INFO Chromecast version 3.0.0.31
        Feb-24 17:39:48 INFO Connecting to Bedroom Speaker https://172.17.17.45:8009/
        Feb-24 17:39:48 INFO Connecting to Kitchen Speaker https://172.17.17.50:8009/
        Feb-24 17:39:48 INFO Connecting to Living Room Speaker https://172.17.17.44:8009/
        Feb-24 17:39:48 INFO Connecting to Living Room TV https://172.17.17.28:8009/
        Feb-24 17:39:48 INFO Connecting to Everywhere https://172.17.17.46:42324/ <--GROUP
        Feb-24 17:39:48 INFO Connecting to Inside https://172.17.17.46:42738/ <--GROUP
        Feb-24 17:39:48 INFO Connecting to Office Speaker https://172.17.17.46:8009/
        Feb-24 17:39:48 INFO Connecting to Dining Room Speaker https://172.17.17.47:8009/
        Feb-24 17:39:48 INFO Connecting to Roaming Speaker https://172.17.17.49:8009/
        Feb-24 17:39:48 INFO Connecting to Announcements https://172.17.17.46:42041/ <--GROUP
        Feb-24 17:39:48 INFO Connecting to Outside speaker https://172.17.17.49:42128/
        Feb-24 17:39:52 INFO Connected to chromecast Bedroom Speaker
        Feb-24 17:39:52 INFO Connected to chromecast Kitchen Speaker
        Feb-24 17:39:52 INFO Connected to chromecast Living Room Speaker
        Feb-24 17:39:52 INFO Connected to chromecast Living Room TV
        Feb-24 17:39:52 INFO Connected to chromecast Roaming Speaker
        Feb-24 17:39:52 INFO Connected to chromecast Inside
        Feb-24 17:39:52 INFO Connected to chromecast Outside speaker
        Feb-24 17:39:52 INFO Connected to chromecast Dining Room Speaker
        Feb-24 17:39:52 INFO Connected to chromecast Office Speaker
        Feb-24 17:39:52 INFO Connected to chromecast Everywhere
        Feb-24 17:39:52 INFO Connected to chromecast Announcements

        Comment


        • #5
          Playing a media file it works perfectly

          Sub Main(parm as object)
          hs.PluginFunction("Chromecast", "", "CastMedia", New Object() {"EE4A2C37-E412-484E-B366-2988BF67D408", "http://172.17.17.39/media/tapslow.wav", "audio/wav", "Taps", ""})
          End Sub

          Comment


          • #6
            Also, can i control the volume via script hs.PluginFunction?

            Comment


            • #7
              The Speak function has 2 optional parameters, the second one called "called" host can be use to target one or several specific speaker:
              http://help.homeseer.com/help/HS3/st...wavmedia_speak

              Also from the Chromecast plugin config page you can disable any chromnecast or group for TTS by unchecking the TTS column

              Comment


              • #8
                Originally posted by tmassano View Post
                Yes, creating a long string is possible. But how would I speak it in the script?
                s = string1 & string2
                hs.speak(s)

                Comment


                • #9
                  Thank you everyone. My apologies, I'm not a developer, more of a hacker.

                  My new issue is:

                  hs.speak appears to be overwriting itself when it speaks to the chrome cast multiple times.

                  If I have three hs.speak commands in a script, I only hear the last one. (But it works perfectly with the HS Speaker agent)

                  So I did as baudi suggested, one long string, now I have hit a 200 character limit. If I go over 200 char, the logs show the entire string, but chromecast never speaks it.

                  I hope you can see where i'm going. I could brake it into two strings smaller than 200 each, but I would only hear the last one.

                  Any guidance is appreciated.

                  Comment


                  • #10
                    You need to add delays between the speak statements in your script. However, I frequently have much longer strings than 200 characters. Where do you see that limitation? Maybe post your revised script.
                    HS 3.0.0.531: 1985 Devices 1128 Events
                    Z-Wave 3.0.1.260: 122 Nodes on one Z-Net

                    Comment


                    • #11
                      I believe it to be some sort of chromecast limitation. As I said, it works perfectly with the HS Speaker client.

                      I just used hs.speakToFile, and a very large string worked.

                      So maybe I will dump it to a file, then cast the wav file to chromecast

                      Comment


                      • #12
                        This worked. And I actually like it better because it uses crystals voice ;-)

                        Sub Main(parms As Object)
                        Dim SpeakPhrase As String
                        SpeakPhrase = "Good Morning. I hope you had a restful night sleep. Today is Monday, February 25 2019. it is going to be cold today! Do not forget your jacket! Todays forecast Windy with a few clouds AGAIN Good Morning. I hope you had a restful night sleep. Today is Monday, February 25 2019. it is going to be cold today! Do not forget your jacket! Todays forecast Windy with a few clouds."

                        If SpeakPhrase IsNot " " Then
                        hs.SpeakToFile(SpeakPhrase, "ATT DTNV 1.4 Crystal16", "C:\progra~2\Homese~1\html\media\speak.wav")
                        End If

                        hs.PluginFunction("Chromecast", "", "CastMedia", New Object() {"EE4A2C37-E412-484E-B366-2988BF67D408", "http://172.17.17.39/media/speak.wav", "audio/wav", "HomeSeer Wav File", ""})

                        End Sub

                        Comment


                        • #13
                          Cool, thanks for posting!
                          HS 3.0.0.531: 1985 Devices 1128 Events
                          Z-Wave 3.0.1.260: 122 Nodes on one Z-Net

                          Comment

                          Working...
                          X