Fridge Log

Forum over Homeseer scripts (DUTCH forum)

Moderators: TANE, Ruud

Post Reply
villo01
Starting Member
Starting Member
Posts: 8
Joined: Tue Aug 15, 2006 11:30 pm
Location: Mexico

Fridge Log

Post by villo01 »

Pieter on your web page you have a Fridge Log, I have a wireless sensor in my fridge that I use for status with doomotion and WGL W800, how do you create the log and the bars graphics.
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Fridge Log

Post by Bwired »

Here is a Homeseer script for logging Devices, just add it to the device. The driver in this case is for a MYSQL database, which can be downloaded for free. If you are using MSAccess you only have to change the driver. I would recommend MYSQL instead of MSAccess because Access is rubbish specially when connecting your database to the web and use it also for updates from within Homeseer or other applications (miltiuser part)

In this topic you can find info on how to make charts etc.
http://www.domoticaforum.eu/topic.asp?TOPIC_ID=65


<h4>Homeseer Script</h4>Dim my_conn, strSql, rsp, code, last_change, device_status, last_change_oud

Sub Main()
Set my_conn = createobject("ADODB.Connection")
my_conn.open = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=NAME-DATABASE;UID=XXXXX;PWD=XXXXX;OPTION=35;"
Set rsp = CreateObject("ADODB.Recordset")

StrSql = "SELECT * From Fridge"
rsp.Open strSQL, my_conn, 1, 3

code = hs.GetDeviceCode("Kitchen Fridge")
last_change = hs.DeviceLastChange(code)
device_status = hs.DeviceStatus(code)

If device_status = "3" then
device_status = "On"
End If
If device_status = "2" then
device_status = "Off"
End If

rsp.AddNew
rsp.Fields("Device").Value = "Fridge"
rsp.Fields("Datum").Value = Date
rsp.Fields("Tijd").Value = Time
rsp.Fields("Device_change").Value = last_change
rsp.Fields("Status").Value = Device_status

rsp.Update
rsp.Close
set rsp = nothing
my_conn.close
set my_conn = nothing

End Sub


Pieter Knuvers
www.bwired.nl Online House in the netherlands. Domotica, Home Automation.
User avatar
Richard
Member
Member
Posts: 102
Joined: Sat Aug 12, 2006 11:44 am
Location: Netherlands - Alkmaar

Fridge Log

Post by Richard »

BWired (Peter),

I don't know if this is the right place and the right conclusion but i give it a try.

If the HomeSeer scripting language supports the "else" or "else if" statement then i would suggest that you can make a little evaluation improvement, wich can 'speedup' something. Oke this is a verry (read: verrrrrrrrrrrrry) small point of improvent, but all small pieces will help :) right?

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Bwired</i>
<br />If device_status = "3" then
device_status = "On"
End If
If device_status = "2" then
device_status = "Off"
End If
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Bwired
Administrator
Administrator
Posts: 4704
Joined: Sat Mar 25, 2006 1:07 am
Location: Netherlands
Contact:

Fridge Log

Post by Bwired »

yes you are wright :-) they all work!
The database insert can be much inproved as well with a simple insert statement
villo01
Starting Member
Starting Member
Posts: 8
Joined: Tue Aug 15, 2006 11:30 pm
Location: Mexico

Fridge Log

Post by villo01 »

ok, i will try this script and let you now
Post Reply

Return to “Homeseer Scripts Forum”