Announcement

Collapse
No announcement yet.

Running Events on startup and shutdown

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

  • Running Events on startup and shutdown

    Hi,

    I'm new, so bear with me.

    I'd like to run an event on startup and on shutdown. I know i need to modify the startup and shutdown scripts. The startup script seems to be programmed in vb.net. The shutdown script is a text file. Seems odd to me that they are different. Anyways....any example code out there on how to trigger an event on startup and on shutdown?

    Thank you!

    Floyd

  • #2
    Here is a post on how I do mine. I posted later here with some changes.

    HS can process a .txt file (as VBScript) the same as a VB.NET script. You just need to reference your startup Event with a single line:

    hs.triggerevent("Startup Occurred")
    Randy Prade
    Aurora, CO
    Prades.net

    PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

    Comment


    • #3
      Hi Floyd,

      Yes, the default startup one is in VB.NET whereas the default shutdown one is in VBScript. You can specify the the HS startup and shutdown scripts to use under Tools - Setup - Custom and you can use any of the HS supported scripting languages. Just make sure to use the right extension for the right type (.vb for VB.NET, .txt for VBScript, .c for C#). I use VB.NET scripts for both with names different than the default to eliminate the risk of them being overwritten by the default ones.

      Click image for larger version

Name:	Capture.PNG
Views:	143
Size:	6.3 KB
ID:	1291427

      To trigger an event in VB.NET, use hs.TriggerEvent("Event Name). For VBScript, use hs.TriggerEvent "Event Name"

      Cheers
      Al
      HS 3.0.0.548: 1965 Devices 1146 Events
      Z-Wave 3.0.1.262: 122 Nodes on one Z-Net

      Comment


      • #4
        Thanks guys, much appreciated!

        So I added the line

        hs.TriggerEvent"Shutdown"

        to my shutdown.txt script. I created an event "Shutdown" to send me a Pushover 3P message that HS has shut down when it is manually triggered. I shut down HS3 and no message.

        So, I'm guessing either the script calling the event is not considered a manual trigger, or the Pushover 3P plugin is shut down before the event is run.

        All i want to do is be notified via Pushover 3P when HS3 has started and when it has shut down. Both for informative purposes and for troubleshooting purposes.

        I was gone for a week and my HS3 shut down randomly. I'm not sure why so I'm trying to debug it plus make the system more robust. I recently added a UPS along with the APCUPSD plugin and added a few events to notify me when it's switched to battery and back to line. I activated HSSentry although that does not seem to work very well based on my testing so far. The HS log file did not show any abnormal anomalies.

        Thx,

        Floyd

        Comment


        • #5
          Hi Floyd, take a look at the log file around the time you shut down HS and see if the event triggered (you don't show a space between hs.TriggerEvent and "Shutdown", so that could be an issue). Yes, running it this way would be considered a manual trigger, but there is a good chance the plugin is already down as you suspect. Also, if HS crashes, then it would never run. HSSentry works fine for me, although it's rarely needed on my system).

          Cheers
          Al
          HS 3.0.0.548: 1965 Devices 1146 Events
          Z-Wave 3.0.1.262: 122 Nodes on one Z-Net

          Comment


          • #6
            Originally posted by frdaoust View Post
            I was gone for a week and my HS3 shut down randomly.
            FWIW, HS runs extremely reliably in my experience.
            If HS shuts down unexpectedly, it will most likely not have a chance to run the shutdown script. Even for a normal shutdown, the resources for sending you a message may be unavailable when the script runs.

            If you want to detect an unplanned shutdown you will probably need an external program that has some sort of 'handshake' with HS so it can alert you when the link is broken. Alternatively, you can have HS send you a message on a regular schedule so you can use a missing message as an alert that something may be amiss.

            Mike____________________________________________________________ __________________
            HS3 Pro Edition 3.0.0.548

            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


            • #7
              I use UptimeRobot (UptimeRobot.com) to monitor my HS system, NAS, BlueIris server, etc. It supports up to 50 free monitors (HTTP, ping, port), and each polled every 5 minutes for free. Alert messages are email, sms or voice. The only downside is if your internet connection goes down, my phone receives offline messages for all monitored systems, when they may in fact still be up and running.

              You will also get a message when the affected system comes back online. Their website also tracks all the metrics for you, as well as calculating % uptime. Not bad for a free solution. :-)

              Comment


              • #8
                Originally posted by frdaoust View Post
                Thanks guys, much appreciated!

                So I added the line

                hs.TriggerEvent"Shutdown"

                to my shutdown.txt script. I created an event "Shutdown" to send me a Pushover 3P message that HS has shut down when it is manually triggered. I shut down HS3 and no message.

                So, I'm guessing either the script calling the event is not considered a manual trigger, or the Pushover 3P plugin is shut down before the event is run.

                All i want to do is be notified via Pushover 3P when HS3 has started and when it has shut down. Both for informative purposes and for troubleshooting purposes.

                I was gone for a week and my HS3 shut down randomly. I'm not sure why so I'm trying to debug it plus make the system more robust. I recently added a UPS along with the APCUPSD plugin and added a few events to notify me when it's switched to battery and back to line. I activated HSSentry although that does not seem to work very well based on my testing so far. The HS log file did not show any abnormal anomalies.

                Thx,

                Floyd
                Also make sure it is

                hs.TriggerEvent("Shutdown") (with parenthesis) or it will not run. It doesn't matter what you use as a Trigger for the Event, it will be ignored.

                If you enable HSSentry in settings, HS should restart if it shuts down for any reason.
                Randy Prade
                Aurora, CO
                Prades.net

                PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                Comment


                • #9
                  Originally posted by rprade View Post
                  Also make sure it is

                  hs.TriggerEvent("Shutdown") (with parenthesis) or it will not run. It doesn't matter what you use as a Trigger for the Event, it will be ignored.

                  If you enable HSSentry in settings, HS should restart if it shuts down for any reason.
                  Hi Randy, in VBScript, the () should not be used. If he’s editing shutdown.txt, then it’s correct (assuming he has a space before “Shutdown”).

                  Cheers
                  Al

                  HS 3.0.0.548: 1965 Devices 1146 Events
                  Z-Wave 3.0.1.262: 122 Nodes on one Z-Net

                  Comment


                  • #10
                    Originally posted by sparkman View Post

                    Hi Randy, in VBScript, the () should not be used. If he’s editing shutdown.txt, then it’s correct (assuming he has a space before “Shutdown”).

                    Cheers
                    Al
                    Thanks. I didn't read correctly that he was still using the .txt file. In that case, it still didn't have a space before "Shutdown".

                    Randy Prade
                    Aurora, CO
                    Prades.net

                    PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                    Comment


                    • #11
                      Thank you everyone, I got it working.

                      The first problem was that no shutdown script was configured in the setup. Once i configured the shutdown.txt script in setup it ran the script and triggered the event. However, immediately after triggering the event HS3 shuts down the plugins including Pushover 3P so the message is never sent. I added a wait delay in the shutdown script of two seconds. This is enough time to allow Pushover 3P to send the message before it is shut down. My shutdown.txt script looks like this:

                      hs.TriggerEvent "Shutdown"
                      hs.WaitSecs(2)

                      I also modified the startup script to send a similar message on startup.

                      Now when HS3 does a controlled shutdown it will send a Pushover 3P message. On a sudden crash of HS3 i probably won't get a message as the script won't run.

                      To detect when HS3 isn't running I would need some type of external software watchdog. However isn't this what HSSentry is for. I would be nice if HSSentry had some configuration parameters to send some type of message when it detects that HS3 has shut down.

                      Thanks again,

                      Floyd

                      Comment


                      • #12
                        Originally posted by frdaoust View Post
                        . . .I also modified the startup script to send a similar message on startup.

                        Now when HS3 does a controlled shutdown it will send a Pushover 3P message. On a sudden crash of HS3 i probably won't get a message as the script won't run.

                        To detect when HS3 isn't running I would need some type of external software watchdog. However isn't this what HSSentry is for. I would be nice if HSSentry had some configuration parameters to send some type of message when it detects that HS3 has shut down.
                        If your startup script sends you a message when HS restarts, can't you use that as a signal that HS stopped?

                        Mike____________________________________________________________ __________________
                        HS3 Pro Edition 3.0.0.548

                        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


                        • #13
                          Originally posted by Uncle Michael View Post
                          If your startup script sends you a message when HS restarts, can't you use that as a signal that HS stopped?
                          Yes, I agree. I’m just being a bit anal. I’d like to know when it shut down, when it starts, etc.

                          Thanks for the reply Uncle Mike !


                          Sent from my iPhone using Tapatalk

                          Comment


                          • #14
                            Originally posted by jhirschhorn View Post
                            I use UptimeRobot (UptimeRobot.com) to monitor my HS system, NAS, BlueIris server, etc. It supports up to 50 free monitors (HTTP, ping, port), and each polled every 5 minutes for free. Alert messages are email, sms or voice. The only downside is if your internet connection goes down, my phone receives offline messages for all monitored systems, when they may in fact still be up and running.

                            You will also get a message when the affected system comes back online. Their website also tracks all the metrics for you, as well as calculating % uptime. Not bad for a free solution. :-)
                            Could you go into more detail on how you set up Uptime Robot? It seems like a great solution to receive positive notification when HS3 is down, but I am unclear on how to set it up, and there are no real details on the website. Thanks!

                            Comment


                            • #15
                              Verify you can connect to Homesser via a PUBLIC address, not local.
                              unless you have a static IP, set up a Dynamic DNS name (DDNS. There are many free options available NOIP.com DYNU.com DUCKDNS.org)
                              and configure port forwarding thru your router.

                              Once you can successfully connected to HS via a public address:

                              1) Create a free account on the Uptimerobot website.

                              2) Click green "My Settings" on top menu bar. "Add Alert Contact" (right side), and set up an "Alert Contact" (your email address, or for text message, your phone #@your carrier's webaddress)

                              3) Click green "Add New Monitor" (left side)
                              Monitor Type: HTTP
                              Friendly Name: Homeseer
                              URL: whatever your public IP is, and the port forwarded thru your router.
                              Set monitoring interval to whatever you like (every 15-30 minutes I find is sufficient)
                              4) Click Advanced Settings, show (below)
                              Enter a Homeseer username and password. (create an account on Homeseer) guest permissions for this. No need for Admin and why risk exposing your primary HS login)
                              Authentication: HTTP Basic
                              5) Select an Alert Contact To Notify (check box top right) that you previously set up in step 2.

                              6) Save Changes

                              Wait for its monitoring interval, and hopefully it turns green indicating a success.

                              Click image for larger version

Name:	Uptime.JPG
Views:	134
Size:	54.4 KB
ID:	1303854





                              Attached Files

                              Comment

                              Working...
                              X