Announcement

Collapse
No announcement yet.

NOT a scripting person. - How do I send log to a different drive.

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

  • Pervez2602
    replied
    Hi Jon,
    Thanks on two counts.
    Firstly the quick reply
    Secondly and most important the fix.
    Altered the script to"L:" . It came back with an error " *** L:\Logging\Utilities\Power usage\Hourly power usage.txt doesn't exist ***
    Puzzled for a while, then realised I had forgotten to add the directory "Logging".
    Added, tested everything works.
    Really appreciated.

    Peter

    Leave a comment:


  • jon00
    replied
    Change:

    strApPath = hs.getAppPath()

    To:

    strApPath = "L:"

    That should save it to:

    L:\Logging\Utilities\Power usage\Hourly power usage.txt

    Make sure the sub directories exist on the L drive!

    Leave a comment:


  • NOT a scripting person. - How do I send log to a different drive.

    Hi All,
    As it says in the title I am not a scripting person at all but through a serious of trial and error (lots of those) I have managed to cobble together a script to log my hourly power usage, the script saves the values to a .txt file in a folder called Logging on drive D: where HS3 is installed.
    What I would like to do.
    Instead of logging to D:/Program Files (x86)/Homeseer HS3/Logging. I would like to log the results instead to Drive L:/Logging. On the same machine.
    Have tried to set this up with no success.
    Script attached.
    Any help appreciated

    Thanks to all who post there scripts.

    Sub Main (var)
    ''========================================================== =======
    ''****************** LogPowerHourly.vb ****************************
    ''========================================================== =======

    Dim StrRef1 as String ' "CM 119 Total power" (1394)
    Dim StrRef2 as String ' "Power usage last hour" (1397)
    Dim StrRef3 as String ' "Power usage this hour" (206)
    Dim StrRef4 as String ' "Power usage last hour" (1420)

    Dim strFileName as String
    Dim strApPath as String
    Dim strListItem as String
    Dim strDataPath as String = "\Logging\Utilities\Power usage\Hourly power usage.txt"
    ' Dim strTotDevice as String
    Dim strLastChange as String

    Dim IntRef1 as Integer
    Dim IntRef2 as Integer
    Dim IntRef3 as Integer
    Dim IntRef4 as Integer
    Dim IntDev1 as Integer
    Dim IntDev2 as Integer
    Dim IntDev3 as Integer
    Dim IntDev4 as Integer
    Dim IntValue as Integer
    ''========================================================== =======
    IntDev1 = 1394
    IntDev2 = 1397
    IntDev3 = 206
    IntDev4 = 1420

    StrRef1 = hs.DeviceString(IntDev1)
    StrRef2 = hs.DeviceString(IntDev2)
    StrRef3 = hs.DeviceString(IntDev3)
    StrRef4 = hs.DeviceString(IntDev4)
    ''========================================================== =======
    IntRef1 = hs.DeviceValueEx(IntDev1)
    IntRef2 = hs.DeviceValueEx(IntDev2)
    IntRef3 = hs.DeviceValueEx(IntDev3)
    IntRef4 = hs.DeviceValueEx(IntDev4)
    ''========================================================== =======
    '' Get last time the hourly counter was updated to use to set last hour change
    strLastChange = hs.DeviceLastChangeRef(IntDev3)
    ''========================================================== =======
    '' Device values
    IntValue = hs.DeviceValue(IntDev3)
    ' intTot = hs.DeviceValueByName(strTotDevice)
    '' hs.WriteLog("intTot", " = " & IntTot)
    ''========================================================== =======
    '' Find the current path and define a file name
    strApPath = hs.getAppPath()
    ''========================================================== =======
    '' File name of log file
    strFileName = strApPath & strDataPath
    ''========================================================== =======
    '' Log file line
    strListItem = now & chr(9) & StrRef3 & chr(9) & cstr(intValue)
    If System.IO.File.Exists(strFilename) = True Then
    Dim objWriter As New System.IO.StreamWriter(strFileName, True)
    ''========================================================== =======
    '' Write a log entry to the file
    objWriter.WriteLine (strListItem)
    ''========================================================== =======
    '' Close the file
    objWriter.close ()
    ''========================================================== =======
    '' If doesn't exist, do something else
    Else
    hs.WriteLog("Power", "*** " & strFileName & " doesn't exist ***")
    End If
    ''========================================================== =======
    hs.SetDeviceValue(IntDev4,IntRef3) ' Set last hour to current hour
    hs.SetDeviceString(IntDev4, IntRef3 &" Wh's",True)' Last hour string
    IntRef3 = IntRef1-IntRef2 ' This hour calculation
    hs.SetDeviceValueByRef(IntDev3,IntRef3,True)' Set this hour value
    hs.SetDeviceString(IntDev3,IntRef3 &" Wh's",True) ' Set this hour string
    IntRef2 = IntRef1 ' Calc new cumlative hour
    hs.SetDeviceValueByRef(IntDev2,IntRef1,True)' Set cumlative hour value
    hs.SetDeviceString(IntDev2, IntRef1 &" Wh's",True)' Set cumlative hour string
    ''========================================================== =======
    End Sub
    ''========================================================== =======

    Peter

    Current Date/Time: 18/10/2018 16:09:02
    HomeSeer Version: HS3 Pro Edition 3.0.0.435
    Operating System: Microsoft Windows 7 Home Premium - Work Station
    System Uptime: 7 Days 12 Hours 40 Minutes 35 Seconds
    IP Address: 192.168.1.123
    Number of Devices: 474
    Number of Events: 187
    Available Threads: 400
    HSTouch Enabled: True
    Event Threads: 2
    Event Trigger Eval Queue: 0
    Event Trigger Priority Eval Queue: 0
    Device Exec Queue: 0
    HSTouch Event Queue: 0
    Email Send Queue: 0
    Anti Virus Installed: Avast Antivirus

    Enabled Plug-Ins
    3.3.0.0: APCUPSD
    1.0.0.147: Arduino Plugin
    2.0.59.0: BLBackup
    3.0.27.0: BLGData
    2.0.24.0: BLUPS
    3.0.0.50: EasyTrigger
    0.0.0.42: Pushover 3P
    30.0.0.36: RFXCOM
    2.6.2.0: SCSIP
    3.0.6629.22233: Ultra1Wire3
    3.0.6644.26753: UltraLog3
    3.0.0.36: X10
    3.0.1.239: Z-Wave
Working...
X