Setting up HomeSeer to use TEMP08
Home Up Products Parts Store Shopping Center Order Status Request Useful Links Clearance Center Documents Project Status Technical Support

 


Display TEMP08 readings on a web page

  1. Setup TEMP08 to communicate with HomeSeer via the procedure here.
  2. Add the gen_temp_page.txt script below to your HomeSeer Scripts folder.
  3. Change any parameters you need to in the script (highlighted in red);
  • Sensor_qty (currently set to 4)
  • dimensions of hi(x,1), lo(x,1), Sensor_name(x) and Tnow(x) to match Sensor_qty
  • sensor virtual device "house code" ("r" is used here)
  • wind speed sensor (z4 used here)
  • wind gust sensor (z1 used here)
  • wind direction sensor (z7 used here)
  1. Change the Sensor names to match your setup.
  2. Add an event called "Refresh TEMP08" that calls this script on a recurring basis.
  3. Add a link to your new web page "Temp08.html" somewhere.
  4. Have fun!

 

SCRIPT gen_temp_page.txt

'=========================================================================================
' Filename = gen_temp_page.txt v2.0
' Purpose: generate a Sensor status web page for TEMP08
' original author: Rich @ Keware (from gen_status_page.txt)
'
' Vintage Control
' ===============
' created 01-05-2004 by Mitch Matteau
'=========================================================================================
' this script will create a file named "temp08.html" in your HomeSeer "html" directory
' you can add this page as a link off of your HomeSeer personal home page
' the page displays the current temperature information as written to virtual devices
' by the Midon Design TEMP08 One-Wire Serial Interface via script "com1_event.txt"
' For this to work properly you need to create an event named "Refresh TEMP08"
' and set the event to run this script (I set it to run every 10 minutes)
' To see the current outside temperature on HomeSeer's device status page, create a virtual device r1
' Other virtual devices used include;
' r2 Sensor 2 Temperature
' r3 Sensor 3 Temperature
' r4 Sensor 4 Temperature

' r20 Humidity Sensor
' z4 Windspeed

' z1 Wind gust

' z7 wind direction
' note that you need to run this script at least once from within HomeSeer to create the initial page
' to do this, right-click on the event and hit "execute now"
'=========================================================================================

sub main()
Dim Sensor_qty
Sensor_qty=4
Dim Sensor_name(4)
dim hi(4,1)
dim lo(4,1)
dim Tnow(4)

Dim virtual_device

virtual_device="r"

 

dim windspeed

dim wind_dirn

dim wind_gust

 

windspeed = "z4"

wind_dirn = "z7"

wind_gust = "z1"

 

Sensor_name(1)="Sensor 1"
Sensor_name(2)="Sensor 2"
Sensor_name(3)="Sensor 3"
Sensor_name(4)="Sensor 4"

 

Dim Folder, TextStream
dim i,p
dim x,y
dim ndate, ntime
dim temperature
dim S
dim File
dim hilo_date
dim a,b,c,d,e


dim filler
filler = "<TD>&nbsp</TD>"

hs.CreateVar("HILODATE")
hilo_date=hs.GetVar("HILODATE")

'=========================================================================================
' Get Hi and Lo temps from All Sensors
'=========================================================================================

for i = 1 to Sensor_qty
    x = "HI_R"+CStr(i)
    hs.CreateVar(x)
    hi(i,0)=hs.GetVar(x)
    x = "HIT_R"+CStr(i)
    hs.CreateVar(x)
    hi(i,1)=hs.getvar(x)
    x = "LO_R"+CStr(i)
    hs.CreateVar(x)
    lo(i,0)=hs.GetVar(x)
    x = "LOT_R"+CStr(i)
    hs.CreateVar(x)
    lo(i,1)=hs.GetVar(x)
next

'=========================================================================================
' Determine current time/date
'=========================================================================================

a = CStr(year(now))
b = CStr(month(now))
c = CStr(day(now))
d = CStr(time())
if Len(b) = 1 then
    b = "0"+b
end if
if Len(c) = 1 then
    c = "0"+c
end if
today = a+"-"+b+"-"+c+" "+d+" "
a = right(a,2)
ndate = a+"/"+b+"/"+c
ntime = d

'=========================================================================================
' Get current temps from the virtual devices
'=========================================================================================
For i = 1 to Sensor_qty
    x = virtual_device+CStr(i)
    Tnow(i) = hs.DeviceString(x)
next
'=========================================================================================
' Check if the variables need initialization
'=========================================================================================
for i = 1 to Sensor_qty
    if hi(i,0)="" then
        hi(i,0)=Tnow(i)
        hi(i,1)=ntime
    end if
    if lo(i,0)="" then
        lo(i,0)=Tnow(i)
        lo(i,1)=ntime
    end if
next
'=========================================================================================
' Check if today became tomorrow
'=========================================================================================
if hilo_date <> ndate then
    hs.CreateVar("HILODATE")
    hs.SaveVar "HILODATE",ndate
    For i = 1 to Sensor_qty
        x = "HI_R"+CStr(i)
        hs.SaveVar x,Tnow(i)
        x = "HIT_R"+CStr(i)
        hs.SaveVar x,ntime
        x = "LO_R"+CStr(i)
        hs.SaveVar x,Tnow(i)
        x = "LOT_R"+CStr(i)
        hs.SaveVar x,ntime
    Next
else
    For i = 1 to Sensor_qty
        if CSng(hi(i,0)) < CSng(Tnow(i)) then
            hi(i,0) = Tnow(i)
            hi(i,1) = ntime
        end if
        if CSng(lo(i,0)) > CSng(Tnow(i)) then
            lo(i,0) = Tnow(i)
            lo(i,1) = ntime
        end if
        x = "HI_R"+CStr(i)
        hs.SaveVar x,hi(i,0)
        x = "HIT_R"+CStr(i)
        hs.SaveVar x,hi(i,1)
        x = "LO_R"+CStr(i)
        hs.SaveVar x,lo(i,0)
        x = "LOT_R"+CStr(i)
        hs.SaveVar x,lo(i,1)
    Next
end if

'=========================================================================================
' Now create the actual web page (overwrite any existing one)
'=========================================================================================
p = hs.GetAppPath
Set Folder = CreateObject("Scripting.FileSystemObject")
Set TextStream = Folder.CreateTextFile(p+"\html\Temp08.html", True)
'=========================================================================================
' create the header for the html page and include a button for refreshing
'=========================================================================================
TextStream.Write "<html>"
TextStream.WriteBlankLines(1)
TextStream.Write "<Title>TEMP08 Results</Title>"
TextStream.WriteBlankLines(1)
TextStream.Write "<body BGCOLOR=""#D3D3D3"">"
TextStream.WriteBlankLines(1)
TextStream.Write "<H1><CENTER>Current Temperature Information</H1>"
TextStream.WriteBlankLines(1)

TextStream.Write "<form method=""POST"">"
TextStream.Write "<p><input type=""submit"" value=""Refresh TEMP08"" name=""run_event""></p>"

' NOTE: you must have an event created called Refresh TEMP08 that calls this script
TextStream.Write "<p>"
TextStream.Write "<center><p><FONT COLOR=""#0000b0"">"
TextStream.WriteBlankLines(1)
TextStream.Write "<b>The real-time temperature data displayed below is from a "
TextStream.WriteBlankLines(1)
TextStream.Write "<a href=""http://www.midondesign.com/TEMP08/TEMP08.html"">Midon Design Temp08</a> One-Wire Sensor Serial Interface."
TextStream.WriteBlankLines(1)
TextStream.Write " They are connected to my home automation system, running "
TextStream.WriteBlankLines(1)
TextStream.Write "<a href=""http://www.homeseer.com""> HomeSeer</a>,"
TextStream.WriteBlankLines(1)
TextStream.Write " which also acts as a local web server. </b></p> </center>"
TextStream.WriteBlankLines(1)
TextStream.Write "<p></p>"
'=========================================================================================
' now display the actual data
'=========================================================================================
TextStream.Write "<B>Last reading= "+ndate+" "+ntime
TextStream.WriteBlankLines(1)

TextStream.Write "<P>Humidity = "+hs.DeviceString("r20")+"%</P>"

TextStream.WriteBlankLines(1)
TextStream.Write "<P><H2>Temperatures in F</P>"
TextStream.Write "<TABLE BORDER>"
TextStream.Write "<TR><TH>Location</TH><TH>Current</TH><TH>High Today</TH><TH>Time</TH><TH>Low Today</TH><TH>Time</TH></TR>"
TextStream.WriteBlankLines(1)
For i = 1 to Sensor_qty
    x = virtual_device+CStr(i)
    a = "<TR><TD>"+Sensor_name(i)+"</TD><TD ALIGN=CENTER>" + hs.DeviceString(x)+"</TD>"
    b = "<TD ALIGN=CENTER>" + hi(i,0) +"</TD>"
    c = "<TD ALIGN=CENTER>" + hi(i,1) +"</TD>"
    d = "<TD ALIGN=CENTER>" + lo(i,0) +"</TD>"
    e = "<TD ALIGN=CENTER>" + lo(i,1) +"</TD></TR>"
    TextStream.Write a+b+c+d+e
    TextStream.WriteBlankLines(1)
next

TextStream.Write "</TABLE>"

TextStream.WriteBlankLines(1)
TextStream.Write "<P>Wind Speed ="+hs.DeviceString(windspeed)+" MPH"
TextStream.WriteBlankLines(1)

TextStream.Write "<P>Wind Gust was "+hs.DeviceString(wind_gust)+" MPH"
TextStream.WriteBlankLines(1)

TextStream.Write "<P>Wind is from "+hs.DeviceString(wind_dirn)
TextStream.WriteBlankLines(2)

TextStream.Write "<P>Local Sunrise= "+ah.Sunrise
TextStream.Write "<P>Local Sunset= "+ah.Sunset
TextStream.WriteBlankLines(1)

TextStream.Write "</B></p>"
TextStream.WriteBlankLines(1)
TextStream.Write "<a href=""http://www.homeseer.com""><img align=center src=""powered.jpg"" border=0 alt=""HomeSeer logo"">"
TextStream.Write "</CENTER>"
TextStream.Write "</body>"
TextStream.Write "</html>"

TextStream.Close
end sub

 

Return to TEMP08 Project


Last Updated February 03, 2017

midon design 2000-2017

P.O. Box 1784

Suwanee, GA  30024 USA

Please report any problems with this site to