Announcement

Collapse
No announcement yet.

Script help

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Script help

    I have just started getting my feet wet on scripting (more like my little toe). I was able change the Waf net caller Id script to - switch speakers, mute tv, and pause my JRMC player before announcing a call. I was hoping someone could post a simple script for the getspeaker pattern. My next challenge would be to reset the AB8SS back to the previous configuration after a call. If its not to difficult could someone post a script that gets the pattern, changes the pattern(setpattern) and then sets it back to the original?? Or at least explain how this is done?????
    John

    #2
    Howdy, Johnny.

    You may not have noticed, but there is a readme file in the HomeSeer\docs folder of your machine. Here's a quote from it, which will hopefully set you in the right direction for your scripting (my apologies for the formatting). Let us know if you need some help, though.

    And, thanks for helping me take my wife out to dinner!

    --David

    Code:
     SCRIPT FUNCTIONS 
    GetSpeakerPattern()
    Retrieves the pattern of on/off states for the speaker and input relays into a string in the following format:
    			 of 10101010A
    	 Speaker 1 <-|	 ||
    	 Speaker 8 <--------||
    	 A/B <---------------|
    Code example: 
    	 dim s
    	 s = hs.plugin("WAF AB8SS").GetSpeakerPattern
    SetSpeakerPattern(speaker_pattern)
    Sets the pattern of on/off states for the speaker and input relays. After setting the relays, the switcher is queried for its current state, and that state is returned. The input string format and the returned string format are the same as that for the GetSpeakerPattern() function:
    Code example: 
    	 dim s
    	 ' Turn speakers 1-4 on using input A
    	 s = hs.plugin("WAF AB8SS").SetSpeakerPattern("11110000A")
    	 ' Turn speakers 5-7 on using input B
    	 s = hs.plugin("WAF AB8SS").SetSpeakerPattern("00001110B")
    	 ' Turn all speakers off
    	 s = hs.plugin("WAF AB8SS").SetSpeakerPattern("00000000B")
    	 ' Turn all speakers on with Input A
    	 s = hs.plugin("WAF AB8SS").SetSpeakerPattern("11111111A")
    	 ' Display the speaker pattern that was just set.
    	 msgbox s
    Version()
    Returns the version number of the plug-in.
    Code example: 
    	 dim s
    	 s = hs.plugin("WAF AB8SS").version
    SaveSpeakerScene(scene_name,speaker_pattern)
    Saves the supplied speaker pattern in the INI file with the supplied scene name. The scene can be recalled and activated with the SetSpeakerScene command. The input string format is the same as that for the GetSpeakerPattern() function:
    Code example: 
    	 dim s
    	 ' Save the Nighttime scene.
    	 s = hs.plugin("WAF AB8SS").SaveSpeakerScene("Nighttime","10000000A")
    	 ' Save the daytime scene.
    	 s = hs.plugin("WAF AB8SS").SaveSpeakerScene("Daytime","11111111A")
     
    SetSpeakerScene(scene_name)
    Activates a speaker pattern that was saved with the SaveSpeakerScene function
    Code example: 
    	 dim s
    	 ' Activate the Nighttime scene
    	 s = hs.plugin("WAF AB8SS").SetSpeakerScene("Nighttime")

    Comment


      #3
      This is what I have so far. I am looking to return the speaker set up to its original state not the setspeaker pattern that I am using here.


      sub main()
      dim s

      hs.SendIr "Stereo_Main,Mute"
      s = hs.plugin("WAF AB8SS").SetSpeakerPattern("01111100B")

      hs.launch "C:/WINDOWS/system32/mjextman.exe","/Command Stop"
      hs.WaitSecs 4
      hs.SendIr "Stereo_Main,Mute"

      s = hs.plugin("WAF AB8SS").SetSpeakerPattern("00000100B")
      hs.launch "C:/WINDOWS/system32/mjextman.exe","/Command Play"


      end sub
      John

      Comment


        #4
        Johnny,

        Hang in there for a tiny bit longer. I've been working with Doug Lemmon along these same lines, and think we have something working. I'll post the results as soon as I test it tonight. It's nice and simple.

        --David

        Comment


          #5
          David,
          what is your definition of a tiny bit?
          I see this post has over 100 views with no input. Is this getspeaker pattern and set speaker pattern being done by anyone?
          John

          Comment


            #6
            Johnny,

            Yes I have been using it, But recently I have noticed that returning to the original speaker pattern does not seem to be working or at least not wel. I have not had time to troubleshoot it completely.

            I didn't really notice it before, because I did not switch often to another source. But now I am using 2 sources often it is apparent.

            StevenE
            Why oh why didn't I just leave things alone, they had been working.

            Comment


              #7
              Originally posted by johnnybwis
              David,
              what is your definition of a tiny bit?
              I see this post has over 100 views with no input. Is this getspeaker pattern and set speaker pattern being done by anyone?
              Doh! Where's a "Way Back Machine" when you need one? Sorry about that!

              OK, I think this is what will work. What you'll have is two different routines. One will save the current state of the speakers as a scene, then turn all the speakers on, and put in a time delayed call to a second EVENT that will restore the speakers to their original state. The second routine restores the state of the speakers to their pre-call status.

              Just to make that clearer. You're creating two HS events and one script file (which has two routines). You'll have the first HS event triggered upon the phone ringing. It will call the SaveSpeakerState() routine in the script file. The second event you will not have a trigger (manual triggering). Name the second event "RestoreStateBeforePhoneCall" and have it call the RestoreStateBeforePhoneCall() routine in the script file.

              Thus, when the phone rings, your first routine is run, setting the speakers, then HSP will announce CID when it's available, and then 10 seconds later (in my example), the speakers will be reset to how they were before the call.

              Best wishes!

              --David

              Here's the code:

              Code:
               
              [size=2][color=#0000ff]sub SaveSpeakerState()[/color][/size]
              
              [size=2][color=#0000ff]dim[/color][/size][size=2] s[/size]
              [size=2][color=#0000ff]dim[/color] sprior[/size]
              [size=2]sprior=[color=#b0b0b0]hs[/color].[color=#b0b0b0]plugin[/color]([color=#ff00ff]"WAF AB8SS"[/color]).GetSpeakerPattern[/size]
               
              [size=2]s = [color=#b0b0b0]hs[/color].[color=#b0b0b0]plugin[/color]([color=#ff00ff]"WAF AB8SS"[/color]).SaveSpeakerScene([color=#ff00ff]"StateBeforePhoneCall"[/color],[color=#ff0000]cstr[/color](sprior))[/size]
               
              [size=2]s = [color=#b0b0b0]hs[/color].[color=#b0b0b0]plugin[/color]([color=#ff00ff]"WAF AB8SS"[/color]).SetSpeakerPattern([color=#ff00ff]"11111111B"[/color])[/size]
               
              [size=2][color=#b0b0b0]' The 10 represents how many seconds transpire before the speakers are reset[/color][/size]
              [size=2][color=#b0b0b0]hs[/color].[color=#b0b0b0]delayTrigger[/color] 10,[color=#ff00ff]"RestoreStateBeforePhoneCall"[/color][/size]
              [size=2][color=#ff00ff]end sub[/color][/size]
              [size=2][color=#ff00ff][size=2][color=#ff00ff][/color][/size][/color][/size]
              [size=2][color=#ff00ff][size=2][color=#ff00ff]Sub RestoreStateBeforePhoneCall()[/color][/size][/color][/size]
              [size=2][color=#ff00ff][size=2][color=#ff00ff][size=2][color=#0000ff]dim[/color][/size][size=2][color=#000000] s[/color]
               
              [/size][/color][/size][/color][/size][size=2]s = [/size][size=2][color=#b0b0b0]hs[/color][/size][size=2].[/size][size=2][color=#b0b0b0]plugin[/color][/size][size=2]([/size][size=2][color=#ff00ff]"WAF AB8SS"[/color][/size][size=2]).SetSpeakerScene([/size][size=2][color=#ff00ff]"StateBeforePhoneCall"[/color][/size][size=2])
               
              [/size][size=2][color=#ff00ff][size=2][color=#ff00ff]End Sub
              [/color][/size][/color][/size]

              Comment


                #8
                Thanks David
                I was able to insert the code into your "WAF-NetCallerID-Sample-CID-Processing.vbs" script
                This is really cool as it now mutes my tv, or radio, or JR media player. Turns on the appropriate speakers for the caller id and then switches back to the previous speaker set up. This coolness helps take some of the sting out of the recent price increase for the pluggins (sorry had to stick that in there).
                John

                Comment


                  #9
                  Johnny,

                  Cool! Glad to hear it's working well for you. Sorry about the delay in getting back to you. I did mention my three sons are making me senile, didn't I?

                  Originally posted by johnnybwis
                  This coolness helps take some of the sting out of the recent price increase for the pluggins (sorry had to stick that in there).
                  The price increases affect me, too--and I'm a cheapskate! I've been chatting with George P. about how to set up a simple rebate program for the less-complex plug-ins. I am not interested in making more money; I just want to raise funds to take my wife out to dinner every once in a while. I like to share my cheapness with others on the MB by selling my stuff inexpensively. I would've been happier if HST had not raised the minimum price to $30, but had just told us authors that they would take a minimum $9 commission (up from $5). That would have been simpler. We could've just raised our prices by $4 instead of having to look into the accounting/record keeping of a rebate program.

                  Anyway, glad you're up and running.

                  --David

                  Comment


                    #10
                    Still working Great but I do get this error message

                    1/5/2005 5:49:42 AM~!~AB8SS Plug-in Diagnostic~!~Error 13 (Type mismatch) in procedure SetSpeakerScene of User Control hspi

                    Im not too concerned but any ideal why.
                    John

                    Comment


                      #11
                      Johnny,

                      Weird. I'll put that on my to-do list. A type mismatch error occurs when a variable of one type (e.g. numeric) is fed a value in another format (e.g. string).

                      Thanks for pointing it out.

                      --David

                      Comment

                      Working...
                      X