Announcement

Collapse
No announcement yet.

Setting event parameters from a script

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

  • Setting event parameters from a script

    I have a script that creates an event using the NewTimeEvent command.

    hs.NewTimeEvent en,tm, td, 1, 1, 1, 1, 1, 1, 1, "dvff", 1, dv & "-NoMotion.txt",eg

    This is working fine, however I would like to eliminate the need to specify a script and instead put into the event itself the commands that are currently in the script.

    I think I can do this because there are fields in the Actions List to do it if I'm manually editing the event.

    Question is, how do I do it programatically? I do not see anything in the Event Class tor elsewhere hat accesses the appropriate properties.

    Suggestions?

    Frank

  • #2
    Hey Frank:

    Hopefully the geteventByRef function will do what you want. Look it up in the help page; Homeseer has provided an example. Another thing to look at is the addaction function.

    Hope that is what you were looking for...
    Don

    Comment


    • #3
      Originally posted by Zeuster
      Thanks for the note Don.

      I'm already using GetEventByRef and have not been able to get AddAction to work for me.

      What I'd like to do is to use NewTimeEvent like I am today but instead of giving it the name of the script to run, give it the inline code. This way I could build the string on the fly and eliminate numerous scripts (1 for each device the created events deal with).

      Wife's out of town next week so the opportunity to spend unlimited keyboard time figuring this out is near at hand.

      Thanks again Don.

      Frank
      Frank,
      Post what you and one of us can show you how to make the input script a variable. That is what your looking to do correct?
      -Rupp
      sigpic

      Comment


      • #4
        Frank:

        This works for me. Hopefully you can use this snippet of code.
        PHP Code:
           If not hs.EventExists(strRemThen
                   i 
        hs.NewEventGetRef(strRem)
                   
        script1 "showtimeSpeak.vbs" strMsg
                   set ev
        =hs.geteventByRef(i)
                   
        ' msgbox ev.name
                   ev.ev_trig_func = 2
                   ev.ev_abs_time = 0
                   ev.ev_date = ReminderDate
                   ev.ev_time = ReminderTime
                   ev.ev_days = 0
                   ev.group = "TV Reminders"
                   ev.misc = &H10 + &H4000
                   hs.AddAction i,5,script1 
                   set ev = nothing
               end if 
        Don

        Comment


        • #5
          Don,
          What is strMsg defined as?
          -Rupp
          sigpic

          Comment


          • #6
            Originally posted by Rupp
            Don,
            What is strMsg defined as?
            Jeeze! Thanks, Greg for asking. That is the part I was trying to tell Frank, and I forgot to insert it....sigh.
            PHP Code:
             strMsg "(" Chr(34) & "main" Chr(34) & Chr(44) & Chr(34) & Chr(34) & ")" 
            I'm putting a variable into a script so I need to mimic the ("main","variable") syntax.

            Hope that is a little clearer.
            Don

            Comment


            • #7
              Originally posted by Zeuster
              Thanks guys

              Don

              Can you show me showtimeSpeak.vbs.

              It looks to me like you're concatenating things. How is showtimeSpeak.vbs handling srtmsg?

              Frank
              It's adding ("main","variable") to showtimeSpeak.vbs to form:
              showtimeSpeak.vbs("main","variable")
              So this will call the main function and pass in the varible

              Inside showtimeSpeak.vbs theres a function called main like

              sub main(var)
              myVar = var
              ....
              end sub
              -Rupp
              sigpic

              Comment


              • #8
                Frank.

                Rupp has explained it better than I could.

                The idea is to look at a database and pull TV Programs that have titles of interest and speak them a certain time before they show. I also use the Message Server plugin to broadcast the TV Programs to certain PCs. Don't laugh, my stuff isn't pretty. There are some checks to see the state of the speaker switch and if my wife and I are asleep. The message 'x' is created when the program showtime.vbs builds the timed event.



                PHP Code:
                  Sub Main(x)
                  
                'ShowSpeak.vbs
                  
                  '
                Get current state of speaker switch
                      If 
                hs.IsOff("_9")Then 
                          ComputerSpeakers 
                "off"
                      
                Else 
                          
                ComputerSpeakers "on"
                      
                End if
                            
                      
                      
                'Get current state of 'Sleep'
                      If  hs.DeviceStatus("A17") = 3 Then
                          SleepTime = False 
                       Else
                           SleepTime = True
                      End If
                      
                      If SleepTime = False Then
                            If ComputerSpeakers = "off" Then
                              hs.ExecX10 "_9", "on", 0, 0
                              hs.speak x,True
                              hs.ExecX10 "_9", "off",0,0
                          Else
                              hs.speak x,True
                          End if
                      End if
                      hs.plugin("message server").messagetoclient x  ,"TV Alert" ,0,True,False,Client
                    
                   End Sub 
                Don

                Comment

                Working...
                X