Announcement

Collapse
No announcement yet.

Tracking uptime

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

  • Tracking uptime

    hey Vera folks! What's the best way to track uptime on HS3, other than the listed number in Help?

    Of course, assuming this is so much better than Vera... i want to watch it :-)

  • #2
    Go to Plug-Ins and select Manage. From this screen, select Z-Wave. This will display the uptime.

    Comment


    • #3
      You could create a virtual device and run a one-line script through a recurring event:

      Code:
      &nhs.SetDeviceString(1234, "Uptime: " & hs.SystemUpTime, True)
      Replace 1234 with the reference id of the virtual device that you create.

      Cheers
      Al
      HS 3.0.0.548: 1990 Devices 1172 Events
      Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

      Comment


      • #4
        Originally posted by sparkman View Post
        You could create a virtual device and run a one-line script through a recurring event:

        Code:
        &nhs.SetDeviceString(1234, "Uptime: " & hs.SystemUpTime, True)
        Replace 1234 with the reference id of the virtual device that you create.

        Cheers
        Al
        Back at this (per the other thread on variables). If i just want to email an uptime stat every day as part of a report, would this be the easiest way, or is there just a replacement variable i can use?

        Comment


        • #5
          There's no direct replacement variable for that, so you'd have to use the virtual device and the replacement variable for it.


          Sent from my Phone using Tapatalk
          HS 3.0.0.548: 1990 Devices 1172 Events
          Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

          Comment


          • #6
            Originally posted by sparkman View Post
            You could create a virtual device and run a one-line script through a recurring event:

            Code:
            &nhs.SetDeviceString(1234, "Uptime: " & hs.SystemUpTime, True)
            Replace 1234 with the reference id of the virtual device that you create.

            Cheers
            Al
            Thanks for this Al. The output for this script is in days, hours, minutes, and seconds. How can I modify the script so I just get days and hours?

            Comment


            • #7
              Hi Andrew, because of the way HS returns the value, there's no easy way to do it in a one line script and a full script would be needed. There's an example in the HS3 help file using a related command: http://homeseer.com/support/homeseer...emuptimets.htm. I haven't used it myself, but will try it out later today and post a complete script.

              Cheers
              Al
              HS 3.0.0.548: 1990 Devices 1172 Events
              Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

              Comment


              • #8
                Here's a script that provides more format options. Of course, I made it more complex than it needed to be .

                You can specify both a "long" format and a "short" format which are customizable and could be saved into different virtual devices. If no format is specified, then it will default to the "long" format. You can also specify a prefix and suffix to be used in the script.

                Save the script as uptime.vb in the \Scripts folder and run from an event as shown, specifying the reference id of the virtual device to populate and optionally "long" or "short". The device string of the virtual device will be updated with this value and the device value will be set to the up time in minutes. The value can be used to trigger an event (one example would be to send a reminder to restart HS, if it hits a certain number of minutes).

                Cheers
                Al

                Code:
                Sub Main(ByVal Parms as String)
                 
                	Dim Prefix As String = "" 
                	Dim Suffix As String = ""
                
                	Dim Debug as Boolean = False
                	Dim logName As String = "HS3 Uptime"  
                
                	Dim UptimeDevice, upper As Integer 
                	Dim TS As TimeSpan = hs.SystemUpTimeTS
                	If Debug Then hs.WriteLog(logname, TS.ToString)
                	Dim Uptime As String = ""
                	Dim FormatTime As String = ""
                	Dim FormatStyle As String = ""
                	Dim DF As String = ""
                	Dim HF As String = ""
                	Dim MF As String = ""
                
                	If Parms.Length > 0 Then
                		Dim ParmArray() as String
                		ParmArray = Parms.split(",")			'split parameter into an array
                		upper = ParmArray.GetUpperBound(0)
                		If Debug Then hs.WriteLog(logname, upper.ToString)
                		If upper = 1 Then
                			UptimeDevice = CInt(ParmArray(0))
                			FormatStyle = ParmArray(1).ToLower
                		Else If upper = 0 Then
                			UptimeDevice = CInt(ParmArray(0))
                			FormatStyle = "long"
                		End If
                
                		If TS.Days <> 1 Then DF = "\s"
                		If TS.Hours <> 1 Then HF = "\s"
                		If TS.Minutes <> 1 Then MF = "\s"
                
                		'The FormatTime strings need to be in the format specified here: https://msdn.microsoft.com/en-us/library/ee372287(v=vs.110).aspx
                		'regular letters and characters that you want to have in the format need to be preceeded with a \ (backslash)
                		Select Case FormatStyle  
                			Case "short"
                				FormatTime = "dd\.hh\:mm"
                			Case "long"
                				FormatTime = "d\ \d\a\y" & DF & "\,\ h\ \h\o\u\r" & HF & "\,\ m\ \m\i\n\u\t\e" & MF 
                			'Case "medium"
                				'FormatTime = ""
                		End Select
                		If Debug Then hs.WriteLog(logname, FormatTime)
                
                		Try
                			Uptime = Prefix & TS.ToString(FormatTime) & Suffix
                			If Debug Then hs.WriteLog(logname, Uptime)
                			hs.SetDeviceValuebyRef(UptimeDevice, TS.TotalMinutes, True)
                			hs.SetDeviceString(UptimeDevice, Uptime, False)
                		Catch ex As Exception 
                			hs.WriteLog(logName, ex.Message)
                		End Try 
                		
                	Else
                		hs.writelog(logName,"No Parameter Specified.  Device not Set.")
                	End If
                	
                
                End Sub
                Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	24.8 KB
ID:	1188818

                Click image for larger version

Name:	Capture2.PNG
Views:	1
Size:	15.3 KB
ID:	1188819

                Cheers
                Al
                Last edited by sparkman; February 5th, 2017, 01:14 PM.
                HS 3.0.0.548: 1990 Devices 1172 Events
                Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                Comment


                • #9
                  Thanks so much for your generosity with your time and expertise Al. Works perfectly and you've made it so flexible and easy to setup. I had it up and running in just a few minutes.

                  Cheers
                  Andrew

                  Comment


                  • #10
                    Originally posted by abwyatt View Post
                    Thanks so much for your generosity with your time and expertise Al. Works perfectly and you've made it so flexible and easy to setup. I had it up and running in just a few minutes.

                    Cheers
                    Andrew
                    You're welcome Andrew and glad that worked for you!

                    Cheers
                    Al
                    HS 3.0.0.548: 1990 Devices 1172 Events
                    Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                    Comment


                    • #11
                      Hmmm, this is strange. My success with your script was in relation to my HT SEL.

                      But when I install the same script in my Zee S2 and run it I get the following error. Any idea why?

                      Feb-07 11:35:03 PM Error Compiling script /usr/local/HomeSeer/scripts/SystemUptime.vb: Split (System.String[], System.Int32, System.StringSplitOptions)
                      Feb-07 11:35:03 PM Error Compiling script /usr/local/HomeSeer/scripts/SystemUptime.vb: Split (System.String[], System.StringSplitOptions)
                      Feb-07 11:35:03 PM Error Compiling script /usr/local/HomeSeer/scripts/SystemUptime.vb: Split (System.Char[], System.Int32, System.StringSplitOptions)
                      Feb-07 11:35:03 PM Error Compiling script /usr/local/HomeSeer/scripts/SystemUptime.vb: Split (System.Char[], System.StringSplitOptions)
                      Feb-07 11:35:03 PM Error Compiling script /usr/local/HomeSeer/scripts/SystemUptime.vb: Split (System.Char[], System.Int32)
                      Feb-07 11:35:03 PM Error Compiling script /usr/local/HomeSeer/scripts/SystemUptime.vb: Split (ParamArray System.Char[])
                      Feb-07 11:35:03 PM Error Compiling script /usr/local/HomeSeer/scripts/SystemUptime.vb: '(System.String)' of 6 initial candidates
                      Feb-07 11:35:03 PM Error Compiling script /usr/local/HomeSeer/scripts/SystemUptime.vb: After removing narrowing (except object) candidates for method 'Split', nothing was found
                      Feb-07 11:35:03 PM Error Compiling script /usr/local/HomeSeer/scripts/SystemUptime.vb: The import 'System.Core' could not be found.
                      Feb-07 11:34:58 PM Event Running script in background: /usr/local/HomeSeer/scripts/SystemUptime.vb("Main","699,short")

                      Comment


                      • #12
                        Originally posted by abwyatt View Post
                        Hmmm, this is strange. My success with your script was in relation to my HT SEL.

                        But when I install the same script in my Zee S2 and run it I get the following error. Any idea why?
                        Hi Andrew,

                        Not quite sure as Split is a standard vb.net command. Let me do some digging.

                        Cheers
                        Al
                        HS 3.0.0.548: 1990 Devices 1172 Events
                        Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                        Comment


                        • #13
                          Found this thread with a similar issue: https://forums.homeseer.com/showthread.php?t=175822. Try changing the line

                          Code:
                          ParmArray = Parms.Split(",")			'split parameter into an array
                          to

                          Code:
                          ParmArray = Split(Parms,",")			'split parameter into an array
                          Looks like Mono on the PI wants the VisualBasic format, not the VB.NET one which is strange.

                          Let me know if that fixes it.

                          Cheers
                          Al
                          HS 3.0.0.548: 1990 Devices 1172 Events
                          Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                          Comment


                          • #14
                            Originally posted by sparkman View Post
                            Let me know if that fixes it.

                            Cheers
                            Al
                            You're a star Al! Thanks for digging into this. It did fix the problem on the Zee S2.

                            Comment

                            Working...
                            X