Announcement

Collapse
No announcement yet.

Email Notice on HS4 Startup/Shutdown

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

    Email Notice on HS4 Startup/Shutdown

    How can I configure HS to send me an email notice when the system starts up or shuts down? I use Gmail.
    HS4Pro on Windows 10
    One install with 2 Ethernet Z-nets
    2nd install with 1 Ethernet Z-net
    300 devices, 250 events, 8 scripts
    6 CT-100 tstats
    Serial IT-100 interface to DSC Panel with 8 wired zones
    18 Fortrezz water sensors & two valve controls

    #2
    There is a startup.vb and shutdown.vb script in the scripts directory. You would put your code in there. I just use them to announce that HS has started up and is shutting down.

    Edit:

    You don't have a lot of time to do things during a shutdown. So might I suggest you use TapiTalk to just send you an text message instead?

    Comment


      #3
      The startup.vb script runs when HS starts, and you can add commands to that script. I run an event from it, cleverly named "Startup Stuff" that, among other things starts a timer.
      When the timer gets to 10 minutes, it sends me a message that HS has restarted.
      I wait 10 minutes to allow the HS restart process to complete. That assures that email has been initiated and that the startup has, in fact, run to completion.
      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548, NUC i3

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

      Comment


        #4
        Thank you both! Two questions:
        1. I am not a script guy...can you point me to a script example that will open gmail on Windows 10 and send the email?
        2. I am unfamiliar with TapiTalk...how do I go about that set up?
        HS4Pro on Windows 10
        One install with 2 Ethernet Z-nets
        2nd install with 1 Ethernet Z-net
        300 devices, 250 events, 8 scripts
        6 CT-100 tstats
        Serial IT-100 interface to DSC Panel with 8 wired zones
        18 Fortrezz water sensors & two valve controls

        Comment


          #5
          To trigger an event on startup you just need to edit (homeseer)/scripts/Startup.vb to have this at the end:

          Code:
              hs.TriggerEvent("Startup")
          End Sub
          Then you don't need to write a script - configure email in the normal settings, and then there's an action in an event to send an email, like below. I included a short wait as someone suggested to ensure startup is complete.


          Click image for larger version

Name:	startupevent.PNG
Views:	175
Size:	581.9 KB
ID:	1412477

          Comment


            #6
            Elegant and simple...thank you!
            HS4Pro on Windows 10
            One install with 2 Ethernet Z-nets
            2nd install with 1 Ethernet Z-net
            300 devices, 250 events, 8 scripts
            6 CT-100 tstats
            Serial IT-100 interface to DSC Panel with 8 wired zones
            18 Fortrezz water sensors & two valve controls

            Comment


              #7
              I'm getting an error that seems to break the startup.vb, any idea what it means?

              8/19/2020 8:02:33 PM
              HomeSeer Error Compiling script Startup.vb: compiler initialization failed unexpectedly: The system cannot find the file specified.
              8/19/2020 8:02:33 PM
              HomeSeer Error Compiling script Startup.vb: could not find library 'Scheduler.dll'

              HS4Pro on Windows 10
              One install with 2 Ethernet Z-nets
              2nd install with 1 Ethernet Z-net
              300 devices, 250 events, 8 scripts
              6 CT-100 tstats
              Serial IT-100 interface to DSC Panel with 8 wired zones
              18 Fortrezz water sensors & two valve controls

              Comment


                #8
                Did you have a Startup.vb before, or did you have to create one?

                I'd try a few steps:

                1. No Startup.vb

                2. Basic Startup.vb
                Code:
                Sub Main(parm as object)
                  hs.WriteLog("Startup", "Running Startup.vb")
                End Sub
                3. Full Startup.vb with all your extra bits.

                If it fails at 1 or 2 - sorry, I have no idea what would cause it.

                If it fails at 3 - your code is invalid. Typical cause of "odd" errors is not closing blocks (e.g. missing End Sub or End If), because the script that gets compiled has a bunch of extra HomeSeer stuff at the start and end which obscures the error.

                Comment


                  #9
                  Here is my startup.vb. Just put it in your scripts directory in the HS main folder.

                  I use it to announce that the system is starting up and do some testing to make sure all is copacetic.

                  You don't have to create any events, just go to the HS config Tools-> Setup -> Custom

                  Scroll to the bottom and put in startup.vb in the startup line.
                  If you also notice you can do stuff during shutdown as well. I also announce that it's going down.

                  g

                  Code:
                  ' 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
                  
                  
                  End Sub

                  Comment


                    #10
                    Thank you all. RGE was correct, I had the event poorly located in the startup.vb. I moved it and everything worked correctly. Thank you all again.
                    HS4Pro on Windows 10
                    One install with 2 Ethernet Z-nets
                    2nd install with 1 Ethernet Z-net
                    300 devices, 250 events, 8 scripts
                    6 CT-100 tstats
                    Serial IT-100 interface to DSC Panel with 8 wired zones
                    18 Fortrezz water sensors & two valve controls

                    Comment

                    Working...
                    X