Ok, here is how i did it. its not perfect but its close.
First off you need an object called Alarm Status that looks like this:
- Alarm Status object
- Alarm status.jpg (33.75 KiB) Viewed 10051 times
This stores an alpha list with the variables in it, the file path and the flag to choose if to log to the file or not.
Here is a modified version of Richard's script. I added the preface to allow it to be run as a task. I also modified the output to support 2 variables and removed some of the dashes in the file.
Code: Select all
Option Explicit
Dim CurTemp 'this is the inside temp from thermostat
Dim OutTemp ' this is the outside temp from weather device
CurTemp = GetPropertyValue("Thermostat 1.Current Temperature")
OutTemp= GetPropertyValue("Weather.Current Temperature")
if len(OutTemp) > 4 then ' this is to trim out the °F
OutTemp=Left(OutTemp,3)
else
OutTemp=Left(OutTemp,2)
end if
Call WriteLog("On",CurTemp,OutTemp) 'call writelog with the 2 variables above
'-------------------------------------------------------
'- Write Log Line --------------------------------------
' Written by R N
' usage writelog(write to file?,var1,var2)
'-------------------------------------------------------
Sub WriteLog(strLogFlag, strLogLine,strLogLine2)
Dim FileSystem
Dim StdOut
Dim FileName
Dim AlarmLog
Dim LogLines
Dim LogCount
Dim nit
On Error Resume Next
If strLogFlag = "On" Then // are we logging to file?
AlarmLog = GetPropertyValue("Alarm Status.Log")
If AlarmLog = "No items present" Then
AlarmLog = ""
End If
LogLines = Split(AlarmLog, vbLF)
LogCount = UBound(LogLines)
AlarmLog = "*S-" & vbTAB & GetPropertyValue("System Time.TimeAndDate") & " " & strLogLine & " " & strLogLine2 'write to alphalist
If LogCount > 300 Then
LogCount = 300
End If
For nit = 0 to LogCount
LogLines(nit) = Replace(LogLines(nit), "*S-", "")
AlarmLog = AlarmLog & vbLF & LogLines(nit)
Next
SetPropertyValue "Alarm Status.Log", AlarmLog
Sleep 150 'Keep this Sleep here to prevent LogLines to be overwritten because of delay between HouseBot and script
If GetPropertyValue("Alarm Status.Log Switch File") = "On" Then
FileName = GetPropertyValue("Alarm Status.Log File Path")
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set StdOut = FileSystem.OpenTextFile(FileName, 8, True)
If Err.Number = 0 Then
StdOut.Write Date & " " & FormatDateTime(Time,4) & " " & strLogLine & " " & strLogLine2& vbCRLF 'here is where we write the variables to a file
StdOut.Close
Else
Status = Err.Description
Err.Clear
End If
Set StdOut = Nothing
Set FileSystem = Nothing
End If
End If
strLogLine = ""
End Sub
the script is run from a task which runs once an hour and updates 2 dynamic images to allow viewing on SWremotes.
this is a sample of the file:
4/24/2010 01:37 75 72
4/24/2010 02:37 75 72
4/24/2010 03:37 75 72
4/24/2010 04:37 75 72
4/24/2010 05:37 75 72
4/24/2010 06:37 74 72
4/24/2010 07:37 74 72
4/24/2010 08:37 74 72
4/24/2010 08:48 74 72
4/24/2010 09:37 74 72
4/24/2010 10:37 74 72
4/24/2010 11:37 74 72
4/24/2010 12:27 75 72
4/24/2010 12:37 75 72
4/24/2010 13:37 76 74
4/24/2010 14:37 77 71
4/24/2010 15:37 75 71
4/24/2010 16:37 75 69
4/24/2010 17:37 75 66
4/24/2010 18:37 77 64
4/24/2010 19:37 77 63
4/24/2010 20:37 76 61
what is important is GNUPLOT needs the columns seperated by spaces and the time and date format needs to be exact.
Lets look at the GNUPLOT part.
- task.zip
- Support files
- (204.6 KiB) Downloaded 691 times
the following files need to be placed in the c:\program files\gnuplot\binary folder.
buildgraph.plt and buildgraph.bat
The bat file copies the alarmlog.txt file from the housebot dir to the gnuplot binary dir then copy the 2 output png's to my theme dir.
the plt file is preset to do a dual line graph with outside and inside temps.
This should be the result:
- Result
- webdt.jpg (73.8 KiB) Viewed 10051 times
I hope this is clear and helps,
Most of the code belongs to others on this site.
This can be expanded to more variables to graph as needed. I am still trying to work out how to style the graph better so it fits in with my theme.
Let me know if you have any questions.
Thanks to everyone for helping me get this far.
Raptor