HomeSeer MySQL device status
Posted: Tue Nov 06, 2012 4:18 pm
In the past i used Domotiga and a php script to pull device status data from the database. This way i could create Cacti graphs of my device status
Now i`m using HomeSeer and would like to achieve the same. I have found the following script
http://www.iease.nl/2012/02/15/homeseer-mysql-2-2/
But i get the following error
C:\Program Files\HomeSeer HS2\Scripts\statusCallBack.vb
------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
C:\Program Files\HomeSeer HS2\Scripts\Startup.txt
De volgende regel toegevoegd net boven End Sub
Now i`m using HomeSeer and would like to achieve the same. I have found the following script
http://www.iease.nl/2012/02/15/homeseer-mysql-2-2/
But i get the following error
Code: Select all
6-11-2012 15:14:15 - Error - Script compile error: Het type MySqlConnection is niet gedefinieerd.on line 21
------------------------------------------------
Code: Select all
Imports System.Data
Imports MySql.Data.MySqlClient
Dim Public ID As String = "statusCallBack.vb"
Sub checkStatus(ByVal aParm as Object)
dim stat, hc, dc, hdc,refID, sName as String
Dim conn As MySqlConnection
Dim myCommand As New MySqlCommand
Dim varDate as String
Dim varTime as String
Dim varDeviceName as String
Dim varDeviceCode as String
'---------------------------------------------------------------
'PLACE THIS STATEMENT IN YOUR STARTUP SCRIPT
' hs.RegisterStatusChangeCB "statusCallBack.vb","checkStatus"
'---------------------------------------------------------------
hc = aParm(0)
dc = aParm(1)
stat = aParm(2)
refID = aParm(3)
hdc = hc & dc
Dim device
Dim dn
Dim type as String
Dim tijd
tijd = Datepart("yyyy",Now()) & "-" & Right("0" & DatePart("m",Now()),2) & "-" & Right("0" & DatePart("d",Now()),2) & " " & Right("0" & DatePart("h",Now()),2) & ":" & Right("0" & DatePart("n",Now()),2) & ":" & Right("0" & DatePart("s",Now()),2)
device = hs.GetDeviceByRef(refID)
dn = device.name
'
'Detect type of device
'
Select Case (hc)
Case "#"
type = "temp"
Case "$"
type = "minmax"
Case "["
type = "ping"
Case "A"
type = "Schakelaar"
Case "C"
type = "Schakelaar"
Case "H"
type = "Schakelaar"
Case "K"
type = "Schakelaar"
Case "P"
type = "Schakelaar"
Case "R"
type = "Remeha Calenta"
Case "W"
type = "Weer"
Case "Z"
type = "Server"
Case "_"
type = "Plugwise"
End Select
'hs.writelog(ID,"House Code: " & hc & " Device Code " & dc & " Status: " & stat & " Device Value: " & hs.DeviceValue(hdc) & " Device String: " & hs.DeviceString(hdc) & " Name: " & dn & " Type: " & type & " Time: " & tijd)
conn = New MySqlConnection()
conn.ConnectionString = "server=localhost; user id=xxxxxxx; password=xxxxxxxx; database=HomeSeerDB"
Try
conn.Open()
'hs.writelog ("mySQL", "Connection Opened Successfully!")
myCommand.CommandText = "INSERT INTO tbldevices (hc,devicename,type,dc,value,status,ts)" & " VALUES ('" & hc & "','" & dn & "','" & type & "','" & dc & "','" & hs.DeviceValue(hdc) & "','" & stat & "','" & tijd & "')"
myCommand.Connection = conn
myCommand.ExecuteNonQuery()
'hs.writelog ("mySQL", "Logged to database: " & varDeviceName & ", " & varDeviceCode & ", " & iStatus)
conn.Close()
Catch myerror As MySqlException
hs.writelog ("mySQL", "Error Connecting to Database: " & myerror.Message)
End Try
End Sub
C:\Program Files\HomeSeer HS2\Scripts\Startup.txt
De volgende regel toegevoegd net boven End Sub
Code: Select all
hs.RegisterStatusChangeCB "statusCallBack.vb","checkStatus"