I am very happyWith the 2gig CT 30 thermostat. I haven't been able to output figure out how to log the temperatures periodically. I see there are commands to log data into the main log file. Is there a way to do this into another file? Any tips appreciated. Thank you in advance Kevin
Announcement
Collapse
No announcement yet.
How to log temperature changes periodically?
Collapse
X
-
I dont know if it will help, but I just setup a recurring event that runs every 15 mins and log the temperatures to a SQL Server database. It requires a script that just grabs whatever temperature is in the virtual device and uses that value. If you want the script, let me know...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
-
Originally posted by kbrady View PostI see there are commands to log data into the main log file. Is there a way to do this into another file?Mike____________________________________________________________ __________________
HS3 Pro Edition 3.0.0.548, NUC i3
HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti
Comment
-
Yes - the data is in the database, so you can graph it just about any way you want. It requires SQL Server Express, however, you can just change the connection string for other databases.
I will say that Michael's solution is much more out-of-the-box than my approach:
PHP Code:Imports System.Data.SqlClient
Public Const SENSOR_LIST As String = "#11,#18,#9,#14,#4,#7,#16,#22,Q16,Q11"
Public Const CONN As String = "Server=HOMESEER\SQLEXPRESS;Database=temperature;integrated security=SSPI;"
Public Sub Main(ByVal Parms As Object)
Dim s As New SqlConnection
Dim c As SqlCommand
Dim sensors As String = SENSOR_LIST
Dim ary() As String
Dim i As Integer
ary = Split(sensors, ",")
s.ConnectionString = CONN
Try
s.Open()
For i = 1 To UBound(ary)
If (CDbl(hs.DeviceValue(ary(i))) > 0) Then
''ugh - Z-Wave temperature is xxxx whereas RFXCOM temperatures are xxx
If (Left(ary(i), 1) <> "#") Then
c = New SqlCommand("INSERT INTO [temperature].[dbo].[temperature] ([device],[temperature],[dateTime]) " & _
"VALUES('" & ary(i) & "'," & CDbl(hs.DeviceValue(ary(i))) / 10.0 & ",getdate())", s)
Else
c = New SqlCommand("INSERT INTO [temperature].[dbo].[temperature] ([device],[temperature],[dateTime]) " & _
"VALUES('" & ary(i) & "'," & CDbl(hs.DeviceValue(ary(i))) & ",getdate())", s)
'''" & hs.DeviceLastChange(ary(i)) & "'
End If
c.ExecuteNonQuery()
End If
Next i
Catch ex As Exception
hs.WriteLog("temperature", ex.Message)
Finally
s.Close()
c = Nothing
s = Nothing
End Try
End Sub
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
-
Originally posted by cabbage View Postrmasonjr,
is there a way to produce graphs for HSTouch using the database?
I have a collection of scripts I have written I need to tie together, so I want to learn more about writing to databases, thanks for the example.
Cabbage
PHP Code:Public Sub BuildGraphV2(ByVal parms As Object)
Dim data0(999) As Double
Dim data1(999) As Double
Dim labels(999) As String
Dim c As XYChart = New XYChart(300, 180, &HFFFFC0, &H0, 1)
Dim layer As LineLayer
Dim d As Date = Now()
Dim i, hr As Integer
Dim temperature, min, max As Double
Dim s As New SqlConnection
Dim cm As SqlCommand
Dim sqlDr As SqlDataReader = Nothing
Try
s.ConnectionString = CONN
s.Open()
''dataset0 - use its labels
cm = New SqlCommand("select device,temperature,datetime,datepart(hour,datetime) as hour from temperature where device='#9' and datetime>=dateadd(hour,-24,getdate()) and datepart(minute,datetime)=0 order by datetime", s)
sqlDr = cm.ExecuteReader
While (sqlDr.Read)
temperature = CDbl(sqldr(1)) / 10.0
data0(i) = temperature
If (temperature > max) Then
max = temperature
End If
If (temperature < min Or min = 0) Then
min = temperature
End If
hr = CInt(sqlDr(3))
If (hr < 12 And hr > 0) Then
labels(i) = CStr(hr) & "a"
Else
If (hr = 12) Then
labels(i) = "12p"
Else
If (hr = 0) Then
labels(i) = "12a"
Else
labels(i) = CStr(hr - 12) & "p"
End If
End If
End If
i += 1
End While
ReDim Preserve data0(i - 1)
ReDim Preserve labels(i - 1)
i = 0
sqlDr.close()
''dataset1
cm = New SqlCommand("select device,temperature,datetime,datepart(hour,datetime) as hour from temperature where device='#16' and datetime>=dateadd(hour,-24,getdate()) and datepart(minute,datetime)=0 order by datetime", s)
sqlDr = cm.ExecuteReader
While (sqlDr.Read)
temperature = CDbl(sqldr(1)) / 10.0
data1(i) = temperature
If (temperature > max) Then
max = temperature
End If
If (temperature < min Or min = 0) Then
min = temperature
End If
i += 1
End While
ReDim Preserve data1(i - 1)
c.setPlotArea(45, 35, 240, 120, &HFFFFFF, -1, -1, &HC0C0C0, -1)
c.addLegend(45, 12, False, "", 8).setBackground(Chart.Transparent)
c.addTitle("Temperature", "Arial Bold", 9, &HFFFFFF).setBackground(c.patternColor(New Integer() {&H4000, &H8000}, 2))
c.yAxis().setLabelFormat("{value}")
c.xAxis().setLabels(labels)
layer = c.addLineLayer()
layer.addDataSet(data0, &HCF4040, "Outside").setDataSymbol(Chart.SquareSymbol, 7)
layer.addDataSet(data1, &H40CF40, "Wiring Closet").setDataSymbol(Chart.DiamondSymbol, 9)
''layer.setDataLabelFormat("{value|0}")
c.xAxis().setLabelStep(5)
c.yAxis.setLinearScale(min - 1, max)
c.makeChart("C:\Program Files\HomeSeer 2\html\Images\temperature.jpg")
Catch ex As exception
hs.writelog("temperature", ex.message)
Finally
s.close()
End Try
End Sub
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
-
Originally posted by rmasonjr View PostIt requires SQL Server Express, however, you can just change the connection string for other databases.HW - i5 4570T @2.9ghz runs @11w | 8gb ram | 128gb ssd OS - Win10 x64
HS - HS3 Pro Edition 3.0.0.435
Plugins - BLRF 2.0.94.0 | Concord 4 3.1.13.10 | HSBuddy 3.9.605.5 | HSTouch Server 3.0.0.68 | RFXCOM 30.0.0.36 | X10 3.0.0.36 | Z-Wave 3.0.1.190
Hardware - EdgePort/4 DB9 Serial | RFXCOM 433MHz USB Transceiver | Superbus 2000 for Concord 4 | TI103 X-10 Interface | WGL Designs W800 RF | Z-Net Z-Wave Interface
Comment
-
The scripts I use are all using SQL Server Express 2008. Over the years, I've used Access, MySQL and SQL Server. I might go SQLite at some point just to become more familiar with it.
Just FYI - SQL Server Express plays nicely alongside HomeSeer. Hardly any CPU Usage at all. In fact, the HomeSeer Speaker client uses more CPU: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
-
Access is good for quick construction and small database sizes. I use SQL Server for my real data collection needs. I have done mySQL too, but just never had a need with SQL Server resident. SQLite is a little different animal as it does not have rich set of data types available with the others. Dates need particular attention. mcsTemperature has Access and SQL Server support. I have all four in mcsSprinklers and only SQLite in the plug computer version of mcsSprinklers.
Comment
-
Originally posted by cabbage View PostI am a complete novice when it comes to databases, could you give me a rough idea of what i need to setup before the posted scripts will do anything? I have installed SQL Express 2008.
Cabbage
Right-click on databases and create a new database called 'temperature'.
Run the following query to create the temperature table:
USE [temperature]
GO
PHP Code:/****** Object: Table [dbo].[temperature] Script Date: 10/11/2011 06:34:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[temperature](
[temperature_id] [int] IDENTITY(1,1) NOT NULL,
[device] [varchar](4) NULL,
[temperature] [decimal](18, 0) NULL,
[dateTime] [datetime] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
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
-
rmasonjr,
I have gone with an access database which I have successfully logged data in. I have tried your example with chart director, I am getting an error that type XYChart is not defined. I have Imports ChartDirector defined is there anything else I need.
by the way thanks for sharing.
Cabbage
Comment
Comment