Announcement

Collapse
No announcement yet.

Event or Script to create a "Motion Log" ?

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

  • sparkman
    replied
    Here's a simple script that I have been using to write to a log file:

    Code:
    Imports System.IO
    
    Sub Main(ByVal Parms As String)
    
        Dim logName As String = "Log to File"               'set log type for HS log
        Dim Debug As Boolean = False                        'set to True if the script give you errors and it will provide additional info in the HS3 log to help troubleshoot
    
        Try
            Dim ParmArray() As String = Split(Parms,"|")    'split parameter into an array
            Dim refID As Integer = CInt(ParmArray(0))        'the first parameter is the reference id of the device    
            Dim loggingFileName As String = ParmArray(1)    'the second parameter is the file name to log too
    
            Dim CurDate As String = Now.ToString("yyyy-MM-dd")
            Dim CurTime As String = Now.ToString("hh:mm:ss tt")
            Dim CurValue As String = CStr(hs.DeviceValueEx(refID))
    
            Dim mydocpath As String = hs.GetAppPath & "/data/" & loggingFileName & ".csv"
    
            If Debug Then hs.writelog(logName,mydocpath)
            If Debug Then hs.writelog(logName,CurDate & "," & CurTime & "," & CurValue)
    
            Using outputFile As New StreamWriter(mydocpath, True)
                outputFile.WriteLine(CurDate & "," & CurTime & "," & CurValue)
            End Using
    
        Catch ex As Exception
            hs.WriteLog(logName, ex.Message)
        End Try
    
    End Sub
    The script takes two parameters separated by a |, the reference ID of the device and the filename to use for the script. I have a similar script that logs to a SQLite database file.

    Leave a comment:


  • Uncle Michael
    replied
    I think a custom script sounds like the way to go. You could also take a look at the UltraLog plug-in and Jon00's database charting utility. (It allows you to define what you collect in the database. You don't have to chart it.) I suspect, though, that your application is sufficiently unique that doing it yourself is the best way to get what you want.

    Leave a comment:


  • Ltek
    replied
    I'd like to keep a running record, text log file, of motion - full time. This way I can quickly and easily pull up the file and review what motion sensors got triggered, in what order, based on date/time. If it is days ago or only seconds ago, it would be captured in log file. tenHSEvents would need to run 24x7 and see if he'd add a feature to log to a text file. Its probably more than I need... I may just write a script if I cant find anything easier.

    Leave a comment:


  • Uncle Michael
    replied
    Can you provide an example of the information you want to log and how you intend to do the troubleshooting? tenHsEvents can record events for several hours if you filter out highly repetitive things like timers and data logging events. How long after the fact do you want to do your reviews?

    Leave a comment:


  • Ltek
    replied
    Originally posted by Uncle Michael View Post
    Have you tried tenHsEvents? You can filter it down to any devices you want to monitor.
    Didnt know it existed... thank you!

    but looking at it, it doesnt save a viewable log, which is what I want... I dont want realtime. I need for historical review and troubleshooting

    Leave a comment:


  • Uncle Michael
    replied
    Have you tried tenHsEvents? You can filter it down to any devices you want to monitor.

    Leave a comment:


  • Ltek
    started a topic Event or Script to create a "Motion Log" ?

    Event or Script to create a "Motion Log" ?

    Goal: quickly & easily see the sequence of motion events in a given time period without messing with the HS Log, which is difficult to target specfics

    Thought I'd tap the collective before I create something myself.

    Anyone have anything that creates a Log File for specific devices (I just want Motion devices for now) that is viewable on the admin/console website - additional link or whatever to open a separate page or popup, etc?

    Thx!

Working...
X