Announcement

Collapse

Contacting HomeSeer This Week

HomeSeer is open and operational this week. All orders are being processed and shipped as usual. However, some staff are working from home. If you need to contact HomeSeer for support or customer service, please use our Email or Chat options. https://homeseer.com/contact-us/
See more
See less

Announcements scripting?

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

  • Announcements scripting?

    Greetings All !

    Say, I was thinking of writing a script to act as sort of an "announcements wrapper"... and I was hoping to possibly get some tips and examples.

    I figured that I'd write a script that would check to see if my two stereos in the basement (which are plugged into one lamp module) are on. And, if not, turn them on. Raise the volume to maximum. Then, take whatever text was passed to this script / function as a parameter and do an "hs.Speak" of it. Then, bring the volume back down to what it was. And, if the stereos were previously powered-off, turn them back off again.

    The idea would be that instead of using "Speak" steps in my various events, I'd use calls to a single wrapper script and pass it a parameter for the text to be spoken (though I'm not sure how yet to do that with Homeseer).

    I'm new to scripting with Homeseer (though I've done a little bit of work in the past with VB... and I know PHP very well). I'd just like to see some models of how other people are doing this.

    And, who knows? Maybe I'm already going about this the wrong way. Or maybe there are some other checks I might want to make before actually executing the Speak command.


    Thanks!

    -= Dave =-

  • #2
    Dave,

    I think what you're trying to do is make a speech proxy. Does anyone remember if Rick Tinker posted some info on how to do this in the past? I seem to recall that he had. Dave, I believe to make this work well, you might need to write it as a plug-in. Make sure that when you have your TTS spoken that you don't have it done asynchronously, or the script may not wait until the TTS is spoken before executing the follow-on functions you specified.

    The SpeakEasy plug-in will do a number of the things you wish to, in case you get overwhelmed.

    --David

    Comment


    • #3
      Speech wrapper

      Actually, this initial attempt seems to be doing the trick.

      If I create an event to call this script and pass it the function name of "wrap text" and then a parameter of the actual string I want spoken, this will turn on my stereo, if it's off, say the text, then turn off my stereo again.

      I figure I'll just add a few commands for volume control to this.:

      sub main()

      end sub

      Function wrap_text(text_passed)
      text_to_be_spoken=text_passed

      ' note starting status of stereo
      ' if the stereo is already off, turn it on

      if hs.ison("M1") then
      hs.WriteLog "DEBUG", "Stereo is already on."
      stereo_started_as = "ON"
      else
      hs.WriteLog "DEBUG", "Stereo is already off. Turning it on now."
      stereo_started_as = "OFF"
      hs.execx10 "M1", "On", 0, 0, TRUE
      end if


      ' now speak whatever was passed
      hs.Speak text_to_be_spoken

      ' wait for two seconds
      hs.WaitSecs 2


      ' if power was previously off, shut it off again now
      if stereo_started_as = "OFF" then
      hs.WriteLog "DEBUG", "Turning stereo back off."
      hs.execx10 "M1", "Off", 0, 0, TRUE
      end if

      End Function



      Although I'm testing this all remotely and therefore cannot listen to confirm that we're not shutting off the stereo before speaking is complete.... I did try commenting-out the line where it shuts the stereo back off... and confirmed that the stereo indeed was left powered-on.


      -= Dave =-

      Comment


      • #4
        Good show, Dave!

        --David

        Comment

        Working...
        X