Announcement

Collapse
No announcement yet.

How Do i create a new event using script

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

    How Do i create a new event using script

    How Do i create a new event using script.. if you would please give me a good example like it runs at a specific time and executes a script.. thanks so much.

    ~Ghost~

    #2
    Originally posted by ~Ghost~ View Post
    How Do i create a new event using script.. if you would please give me a good example like it runs at a specific time and executes a script.. thanks so much.

    ~Ghost~
    I have never done it but it is going to be similar in style to when you create a device, the event is declared as an object and you can set the options as per the event class. There is the beginnings of a script in the help file;

    Code:
    sub new_event(name)
    
    dim ev
    
    set ev=hs.NewEventEx(name)
    
    ev.group = "System"
    msgbox ev.name
    
    end sub
    which in vb.net I would imagine you would want something like (not tested);

    Code:
    Dim ev As Object
    
    ev = hs.NewEventEx("Event Name")
    ev.ev_abs_time = 0 'this is the type of trigger
    ev.ev_time = "10:00" 'I think this is the correct format
    ev.group = "Test Group"
    
    'then you will need to get the reference for this event to add an action
    
    hs.addaction(hs.GetEventRefByName("Event Name"), 5, "testscript.vb")

    Comment


      #3
      thank you

      Thank you mr. happy for responding so quickly!! one more thing umm it keeps saying
      Error - Running script, script run or compile error in file: Compile New Script1025:Expected end of statement in line 1 More info: Expected end of statement
      i have no clue how to fix this

      thanks
      ~Ghost~
      Last edited by ~Ghost~; July 22, 2012, 01:20 AM.

      Comment


        #4
        Originally posted by ~Ghost~ View Post
        Thank you mr. happy for responding so quickly!! one more thing umm it keeps saying
        Error - Running script, script run or compile error in file: Compile New Script1025:Expected end of statement in line 1 More info: Expected end of statement
        i have no clue how to fix this

        thanks
        ~Ghost~
        Seems to work OK here, ensure you have Sub/End Sub around it and it is named as a .vb file.

        Code:
        Sub Main(ByVal Parms As Object)
        
        Dim ev As Object
        
        ev = hs.NewEventEx("Event Name")
        ev.ev_abs_time = 0 'this is the type of trigger
        ev.ev_time = "10:00" 'I think this is the correct format
        ev.group = "Test Group"
        
        'then you will need to get the reference for this event to add an action
        
        'hs.waitsecs(1)
        
        hs.addaction(hs.GetEventRefByName("Event Name"), 5, "testscript.vb")
        
        
        End Sub
        Just monitor whether you need to put a wait command into the script before you add the action, I can't see that you can add the action from the event class and I am just mindful whether when you get to add the action if the event has been created in the database (probably has but might be worse on a slow PC?). It might be worth waiting a second to add the action to ensure it is created, change testscript.vb to the name of your script.

        Comment


          #5
          thanks Mr. Happy your awesome

          Comment


            #6
            How do i do this in HS3?
            - Bram

            Send from my Commodore VIC-20

            Ashai_Rey____________________________________________________________ ________________
            HS3 Pro 3.0.0.534
            PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

            Comment


              #7
              Originally posted by AshaiRey View Post
              How do i do this in HS3?
              There are less options than in HS2 for event configuration by script (search for the discussions on that one and the reasoning) but you should be able to create it and add some limited actions and have limited triggers. http://www.homeseer.com/support/home...ing_events.htm should get you going.

              Comment


                #8
                Thx for your help on this.
                I did find the help pages already but i ran into some problems there like a 404 on the eventclass page and none of them had any examples. So if you can prove an example then that will be much appreciated. If not i will have to dive in and experiment myself.
                - Bram

                Send from my Commodore VIC-20

                Ashai_Rey____________________________________________________________ ________________
                HS3 Pro 3.0.0.534
                PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

                Comment


                  #9
                  Originally posted by AshaiRey View Post
                  Thx for your help on this.
                  I did find the help pages already but i ran into some problems there like a 404 on the eventclass page and none of them had any examples. So if you can prove an example then that will be much appreciated. If not i will have to dive in and experiment myself.
                  I am afraid I do not have any examples - I have seen a couple posted on this board though, there is perhaps not as much need to create events in this way any more (I barely used it in HS2). There is no event class AFAIK any more.

                  Comment


                    #10
                    Maybe this thread will help: http://board.homeseer.com/showthread.php?p=1146650
                    Jon

                    Comment

                    Working...
                    X