Announcement

Collapse
No announcement yet.

Tracking uptime

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

    #16
    Originally posted by 123qweasd View Post
    Hi Al, I deployed the above script as is/instructed but getting the following error with both "short" and "long"
    Error Initializing script engine: Length cannot be less than zero. Parameter name: length
    Must be missing something simple but can't pinpoint the issue...

    Thanks
    Can you post a screen shot of your event? What version of HS are you running?
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #17
      Here it is; HS3 Pro Edition 3.0.0.548 (Windows)



      Click image for larger version

Name:	GJHYJYTGJ.PNG
Views:	100
Size:	345.4 KB
ID:	1423383


      Comment


        #18
        The short output version can be done as an Immediate Command with the following:
        Code:
        &nhs.SetDeviceString(XXX, hs.SystemUpTimeTS.Days.ToString & "." & hs.SystemUpTimeTS.Hours.ToString & ":" & hs.SystemUpTimeTS.Minutes.ToString, True)
        Just be sure to change XXX to your device ID.
        Karl S
        HS4Pro on Windows 10
        1070 Devices
        56 Z-Wave Nodes
        104 Events
        HSTouch Clients: 3 Android, 1 iOS
        Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

        Comment


          #19
          Originally posted by ksum View Post
          The short output version can be done as an Immediate Command with the following:
          Code:
          &nhs.SetDeviceString(XXX, hs.SystemUpTimeTS.Days.ToString & "." & hs.SystemUpTimeTS.Hours.ToString & ":" & hs.SystemUpTimeTS.Minutes.ToString, True)
          Just be sure to change XXX to your device ID.
          Seems like this would only manage the string. what I like about Al's script is the fact that it also populates device value in minutes. Unless its feasible as a variant of the command above.

          Comment


            #20
            Sorry, I didn't read Al's code, only looked at the screenshot of the devices. So I didn't realize that was being saved. This will do the trick:
            Code:
            &nhs.SetDeviceString(XXX, "Uptime: " & hs.SystemUpTimeTS.Days.ToString & "." & hs.SystemUpTimeTS.Hours.ToString & ":" & hs.SystemUpTimeTS.Minutes.ToString, True) : hs.SetDeviceValuebyRef(XXX, hs.SystemUpTimeTS.TotalMinutes, True)
            Note, however, that running it as a full blown script means the code is compiled and saved so it will be a bit more efficient.
            Karl S
            HS4Pro on Windows 10
            1070 Devices
            56 Z-Wave Nodes
            104 Events
            HSTouch Clients: 3 Android, 1 iOS
            Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

            Comment


              #21
              Originally posted by 123qweasd View Post
              Here it is; HS3 Pro Edition 3.0.0.548 (Windows)
              All looks correct. Can you change the line "Dim Debug as Boolean = False" to "Dim Debug as Boolean = True" and post all the log entries when you try to run it?
              HS 4.2.8.0: 2134 Devices 1252 Events
              Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

              Comment


                #22
                Same output:
                Oct-01 2:40:11 PM Error Initializing script engine: Length cannot be less than zero. Parameter name: length
                Oct-01 2:40:11 PM Event Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/HS UPTIME DEVICE UPDATE (CUSTOM).vb("Main","3886,short")

                Comment


                  #23

                  I think I'm into something here:

                  ksum : both your commands above work as intended with immediate command:

                  Ex:

                  Code:
                  &nhs.SetDeviceString(3888, "Uptime: " & hs.SystemUpTimeTS.Days.ToString & "." & hs.SystemUpTimeTS.Hours.ToString & ":" & hs.SystemUpTimeTS.Minutes.ToString, True) : hs.SetDeviceValuebyRef(3887, hs.SystemUpTimeTS.TotalMinutes, True)
                  but when I try to put them in a script

                  Code:
                  Sub Main(ByVal Parms as String)
                  
                  hs.SetDeviceString(3888, "Uptime custom 2: " & hs.SystemUpTimeTS.Days.ToString & "." & hs.SystemUpTimeTS.Hours.ToString & ":" & hs.SystemUpTimeTS.Minutes.ToString, True) : hs.SetDeviceValuebyRef(XXX, hs.SystemUpTimeTS.TotalMinutes, True)
                  
                  End Sub
                  I get the same error as with Al's script....
                  Oct-01 4:17:45 PM Error Initializing script engine: Length cannot be less than zero. Parameter name: length
                  Oct-01 4:17:45 PM Event Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/HS UPTIME DEVICE UPDATE (CUSTOM 2).vb

                  the scripts must have a .vb extension right?

                  Could it be related to all those changes in the way some commands must be formatted (I'm running HS3 / win10) hs, &hs &nhs, etc....



                  Comment


                    #24
                    Try changing:

                    PHP Code:
                    Sub Main(ByVal Parms as String
                    to


                    PHP Code:
                    Sub Main(ByVal Parms() as String
                    HS4Pro on a Raspberry Pi4
                    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                    HSTouch Clients: 1 Android

                    Comment


                      #25
                      Originally posted by rmasonjr View Post
                      Try changing:

                      PHP Code:
                      Sub Main(ByVal Parms as String
                      to


                      PHP Code:
                      Sub Main(ByVal Parms() as String
                      Same error.... thanks for trying to help.
                      Oct-01 4:46:01 PM Error Initializing script engine: Length cannot be less than zero. Parameter name: length
                      Oct-01 4:46:01 PM Event Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/HS UPTIME DEVICE UPDATE (CUSTOM 2).vb

                      Comment


                        #26
                        I wrote my method as a vb. Yes, it must have a .vb extension. Here is what is working for me. I am not passing anything to the script. Just hard coding the ID:
                        Code:
                        Sub Main()
                        
                        hs.SetDeviceString(XXX, "Uptime: " & hs.SystemUpTimeTS.Days.ToString & "." & hs.SystemUpTimeTS.Hours.ToString & ":" & hs.SystemUpTimeTS.Minutes.ToString, True)
                        
                        hs.SetDeviceValuebyRef(XXX, hs.SystemUpTimeTS.TotalMinutes, True)
                        
                        End Sub
                        Replace XXX with your ID

                        Note also that I am on HS4 so there could be some differences. I do not believe there SHOULD be, though.
                        Karl S
                        HS4Pro on Windows 10
                        1070 Devices
                        56 Z-Wave Nodes
                        104 Events
                        HSTouch Clients: 3 Android, 1 iOS
                        Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                        Comment


                          #27
                          Also, in your code, , the second part still has the device ID as XXX. You need to change it as well. My original 1 line version used a colon ( to separate 2 lines of code. My .vb file version made these 2 lines.
                          Karl S
                          HS4Pro on Windows 10
                          1070 Devices
                          56 Z-Wave Nodes
                          104 Events
                          HSTouch Clients: 3 Android, 1 iOS
                          Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                          Comment


                            #28
                            Got it. Can't use parentheses in script filename... arggg..

                            Oct-01 4:46:01 PM Error Initializing script engine: Length cannot be less than zero. Parameter name: length
                            Oct-01 4:46:01 PM Event Running script in background: C:/Program Files (x86)/HomeSeer HS3/scripts/HS UPTIME DEVICE UPDATE (CUSTOM 2).vb
                            All scripts now working.
                            Would have been nice if the returned error was more obvious....

                            Comment


                              #29
                              Originally posted by 123qweasd View Post
                              All scripts now working.
                              Would have been nice if the returned error was more obvious....
                              Glad you got it sorted. Weird that it does not allow parentheses and yes, the error messages with scripts can be very cryptic.
                              HS 4.2.8.0: 2134 Devices 1252 Events
                              Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

                              Comment


                                #30
                                one option could be to set a timer to 0 and then start it when HomeSeer starts, from the startup.vb script. Or from the startup script just run an eventthat would do all this.

                                Depending of how long your startup.vb takes to run from hs start... you could set the timer to 25-30 secs ( the HS log clearly show that ) then start it from there . This is what I do here , but only for a 5 minutes period for other things

                                Comment

                                Working...
                                X