Announcement

Collapse
No announcement yet.

Run event on startup

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

  • Run event on startup

    Hello

    I'm trying to run an event on startup , basic event to send a pushover notification telling me that HS3 have restarted in case of computer reboot or power outage

    I have zero scripting experience but users here are really helpful so this is what the end of startup script looks like

    ' You may add your own commands to this script.
    ' See the scripting section of the HomeSeer help system for more information.
    ' You may access help by going to your HomeSeer website and clicking the HELP button,
    ' or by pointing your browser to the /help page of your HomeSeer system.
    hs.Launch (hs.GetAppPath & "\Jon00PerfMonHS3.exe","","",0)
    hs.RegisterStatusChangeCB("L2DB-influxdb.vb","Main")
    hs.TriggerEvent ("Startup")

    End Sub
    everything worked fine before adding the " hs.TriggerEvent ("Startup") " , after I add it I get an error in HS3 log

    Jun-07 1:08:07 PM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Startup.vb: 'If', 'ElseIf', 'Else', 'End If', 'Const', or 'Region' expected.
    Jun-07 1:08:07 PM Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\Startup.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
    any idea how to make this work properly ?

    Thanks
    Rami

  • #2
    Originally posted by rmohsen View Post
    everything worked fine before adding the " hs.TriggerEvent ("Startup") " , after I add it I get an error in HS3 log any idea how to make this work properly ?
    Try changing the name of your startup event to something besides "Startup". (I cleverly named mine "Startup Stuff" and it works without a problem.)
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.500

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

    Comment


    • #3
      Originally posted by rmohsen View Post
      hs.TriggerEvent ("Startup")
      Also, it looks like there is a space between the final "t" in hs.TriggerEvent and the first parentheses for the parm. If it's really there, you'll need to remove that.
      Fred

      HomeSeer Pro 3.0.0.478, HS3Touch, Zwave 3.0.1.249, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call

      Comment


      • #4
        Originally posted by rmohsen View Post
        Hello

        I'm trying to run an event on startup , basic event to send a pushover notification telling me that HS3 have restarted in case of computer reboot or power outage

        I have zero scripting experience but users here are really helpful so this is what the end of startup script looks like



        everything worked fine before adding the " hs.TriggerEvent ("Startup") " , after I add it I get an error in HS3 log



        any idea how to make this work properly ?

        Thanks
        Rami
        You can try what Michael suggests, though the errors would indicate that something else in the script might have been changed. I changed the name of mine to "Startup" edited my startup script and it still worked without error. Does the startup script run with the hs.TriggerEvent line commented out or deleted?

        You could post your startup script for other eyes to look at.
        Randy Prade
        Aurora, CO
        Prades.net

        PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

        Comment


        • #5
          Here is my full startup script

          I changed my event name but still gives me the same error , error only occur when I add the event line to the script so I doubt it's an error with the rest of the script

          ' This is the startup script
          ' It is run once when HomeSeer starts up
          '
          ' You may also have Startup.vb and it will be run instead of this script.
          '
          Sub Main(Parm As Object)

          hs.WriteLog("Startup", "(Startup.vb script) Scripting is OK and is now running Startup.vb")

          Dim SpeakClients As String = ""
          SpeakClients = hs.GetInstanceList
          If SpeakClients Is Nothing Then SpeakClients = ""
          If String.IsNullOrEmpty(SpeakClients.Trim) Then
          hs.WriteLog("Startup", "(Startup.vb script) No speaker clients detected, waiting up to 30 seconds for any to connect...")
          ' There are no connected speaker clients, so let's wait 30 seconds
          ' (which is the default re-connect interval for a speaker client)
          ' to see if we can get one connected, otherwise the two speak
          ' commands below will not be heard.
          hs.WaitSecs(1)
          Dim Start As Date = Now()
          Do
          SpeakClients = hs.GetInstanceList
          If SpeakClients Is Nothing Then SpeakClients = ""
          If String.IsNullOrEmpty(SpeakClients.Trim) Then
          hs.WaitSecs(1)
          Else
          Exit Do
          End If
          Loop Until Now.Subtract(Start).TotalSeconds > 30
          End If


          ' Speak - comment the next line if you do not want HomeSeer to speak at startup.
          #hs.Speak("Welcome to Home-Seer", True)

          ' speak the port the web server is running on
          Dim port As String = hs.GetINISetting("Settings", "gWebSvrPort", "")
          If port <> "80" Then
          hs.Speak("Web server port number is " & port)
          End If

          ' You may add your own commands to this script.
          ' See the scripting section of the HomeSeer help system for more information.
          ' You may access help by going to your HomeSeer website and clicking the HELP button,
          ' or by pointing your browser to the /help page of your HomeSeer system.
          hs.Launch (hs.GetAppPath & "\Jon00PerfMonHS3.exe","","",0)
          hs.RegisterStatusChangeCB("L2DB-influxdb.vb","Main")
          hs.TriggerEvent("Startup Stuff")

          End Sub

          Comment


          • #6
            Originally posted by rmohsen View Post
            Here is my full startup script

            I changed my event name but still gives me the same error , error only occur when I add the event line to the script so I doubt it's an error with the rest of the script
            I think the problem might be that you commented out the hs.speak action with a "#"
            Code:
            #hs.Speak("Welcome to Home-Seer", True)
            That is the only thing I see in your script.
            Randy Prade
            Aurora, CO
            Prades.net

            PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

            Comment


            • #7
              Originally posted by rprade View Post
              I think the problem might be that you commented out the hs.speak action with a "#"
              Code:
              #hs.Speak("Welcome to Home-Seer", True)
              That is the only thing I see in your script.
              Thank you , I removed the comment and it worked fine ( it ran the event ) , but gave me a new error , and I also want to disable the hs.speak action, should I just remove it ?

              new error

              Running script L2DB-influxdb.vb :Exception has been thrown by the target of an invocation.->Does entry point Main exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Obj ect obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at A.c17b105f989efe61e5979e67bec1ef734.cffd66cb0782c50126727e3f a75582d7a()

              Comment


              • #8
                Originally posted by rprade View Post
                I think the problem might be that you commented out the hs.speak action with a "#"
                Code:
                #hs.Speak("Welcome to Home-Seer", True)
                That is the only thing I see in your script.
                Just confirmed by loading your script. I get the error and it does not run. Replace the "#" with a single quote and it runs fine.
                Randy Prade
                Aurora, CO
                Prades.net

                PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                Comment


                • #9
                  Originally posted by rmohsen View Post
                  Thank you , I removed the comment and it worked fine ( it ran the event ) , but gave me a new error , and I also want to disable the hs.speak action, should I just remove it ?

                  new error
                  Your error is being generated by this line. Does the script you are calling have a "Main" section?
                  hs.RegisterStatusChangeCB("L2DB-influxdb.vb","Main")
                  For the speak action just comment it out with a single quote.
                  Randy Prade
                  Aurora, CO
                  Prades.net

                  PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                  Comment


                  • #10
                    Originally posted by rprade View Post
                    Your error is being generated by this line. Does the script you are calling have a "Main" section?For the speak action just comment it out with a single quote.
                    Thank you so much , speak action is now disabled , can't figure out the other error , I was trying to get grafana up and running but my lack of scripts knowledge won't let me , I removed the other line and now I don't have any errors , startup event running perfectly

                    Comment

                    Working...
                    X