Announcement

Collapse
No announcement yet.

system uptime script error

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

  • system uptime script error

    script runs as .vb but no population of q3 or q4.

    no log error from script

    /8/2006 8:50:17 AM Info Event Trigger "System Uptime"
    3/8/2006 8:50:17 AM Info Running script in background: HomeSeerUpTime.vb



    script;


    '
    ' define q3 and q4 as status type
    '
    ' Option Explicit

    Const bDEBUG As Boolean = False
    Const strCurUpTimeHCUC As String = "q3"
    Const strMaxUpTimeHCUC As String = "q4"

    Function stripTime (str As String) As String

    Dim strTemp As String

    strTemp = str

    If bDEBUG Then
    Call hs.WriteLog("HomeSeerUpTime", "stripTime Input: '" & strTemp & "'")
    End If

    strTemp = Replace(str, "Days ", "")
    strTemp = Replace(strTemp, "Day ", "")
    strTemp = Replace(strTemp, "Hours ", "")
    strTemp = Replace(strTemp, "Hour ", "")
    strTemp = Replace(strTemp, "Minutes ", "")
    strTemp = Replace(strTemp, "Minute ", "")
    strTemp = Replace(strTemp, "Seconds", "")
    strTemp = Replace(strTemp, "Second", "")
    strTemp = Trim(strTemp) & " "

    If bDEBUG Then
    Call hs.WriteLog("HomeSeerUpTime", "stripTime Output: '" & strTemp & "'")
    End If

    Return strTemp

    End Function

    Function timeSecs(str As String) As Integer

    Dim iDays As Integer
    Dim iHours As Integer
    Dim iMinutes As Integer
    Dim iSeconds As Integer

    If bDEBUG Then
    Call hs.WriteLog("HomeSeerUpTime:timeSecs", "str: '" & str & "'")
    End If

    iDays = Cint(Mid(str, 1, Instr(str, " ")-1))
    str = Mid(str, Instr(str, " ")+1)

    iHours = Cint(Mid(str, 1, Instr(str, " ")-1))
    str = Mid(str, Instr(str, " ")+1)

    If bDEBUG Then
    Call hs.WriteLog("HomeSeerUpTime:timeSecs", "str: '" & str & "'")
    End If

    iMinutes = Cint(Mid(str, 1, Instr(str, " ")-1))
    str = Mid(str, Instr(str, " ")+1)

    If bDEBUG Then
    Call hs.WriteLog("HomeSeerUpTime:timeSecs", "str: '" & str & "'")
    End If

    iSeconds = Cint(Mid(str, 1, Instr(str, " ")-1))

    timeSecs = ((iDays * 24 + iHours) * 60 + iMinutes) * 60 + iSeconds

    End Function

    Sub main (strArg As String)

    Dim strUpTime As String
    Dim iUpTimeSecs As Integer
    Dim iMaxUpTimeSecs As Integer
    Dim strMaxUpTime As String

    strUpTime = hs.SystemUpTime()

    If bDEBUG Then
    Call hs.WriteLog("HomeSeerUpTime:main", "strUpTime: '" & strUpTime & "'")
    End If

    iUpTimeSecs = timeSecs(stripTime(strUpTime))

    Call hs.SetDeviceString (strCurUpTimeHCUC, strUpTime)
    Call hs.SetDeviceLastChange (strCurUpTimeHCUC, Now)

    strMaxUpTime = hs.DeviceString (strMaxUpTimeHCUC)

    If Not Instr(Trim(Ucase(strMaxUpTime)), "UNKNOWN") And _
    strMaxUpTime <> "" Then

    iMaxUpTimeSecs = timeSecs(stripTime(strMaxUpTime))

    If bDEBUG Then
    Call hs.WriteLog("HomeSeerUpTime", "MaxUpTime: '" & iMaxUpTimeSecs.ToString & "'")
    Call hs.WriteLog("HomeSeerUpTime", "UpTime: '" & iUpTimeSecs.ToString & "'")
    End If

    If iUpTimeSecs > iMaxUpTimeSecs Then
    Call hs.SetDeviceString (strMaxUpTimeHCUC, strUpTime)
    Call hs.SetDeviceLastChange (strMaxUpTimeHCUC, Now)
    End If

    Else

    Call hs.SetDeviceString (strMaxUpTimeHCUC, strUpTime)
    Call hs.SetDeviceLastChange (strMaxUpTimeHCUC, Now)

    End If

    End Sub
    Last edited by Richard; March 8th, 2006, 08:26 AM.
    HS3 Standard Edition 3.0.0.258

  • #2
    Error

    It does nothing here as well. I get the following error in my log:

    Running script, script run or compile error in file: HomeSeerUptime.txt1011:Expected '=' in line 3 More info: Expected '='

    I have checked to make sure that I didn't change anything, same script. Running HS 2.1.18

    Comment


    • #3
      Same issue here as well



      Thom

      Comment


      • #4
        I posted an updated version

        Sorry for the troubles... I updated the version in the script library, and added some tips. The key is to add the string "init" to the script parameter the first time it's run. After the script has run once, take the "init" out, and leave a null string ("") The two attached jpg's show what I mean. Hope this clears things up!
        Attached Files

        Comment

        Working...
        X