Setting Up HomeSeer to Read From TEMP05 for V5.00 or higher


Note 1: Ken Mitchell has written a HomeSeer Plug-in for the TEMP05.  This plug-in eliminates the need for the script shown on this page. The beta forum for the plug-in is located here.

Note 2: Michael McSharry has also written a HomeSeer Plug-in for the TEMP05 which adds a database capture and charting.  The forum is located here.

Note 3: The script information on this page refers only to TEMP05 v5.00 or higher.  If you have v4.25 or lower, please use the script information location here.


  1. Make sure that TEMP05 is connected to your COM1 serial port on your HS PC.  If it is not, rename the script below (COM1_EVENT.TXT) to whatever COM port that TEMP05 is connected to.  Save that script in your HomeSeer Scripts folder.
  2. Add the following lines to your "startup.txt" HS script (put them anywhere before the "end sub" line); 
    e=hs.OpenComPort(1,"9600,n,8,1",1,"com1_event.txt","main")
        if e<> "" then
             hs.writelog "Error opening COM1",e
        else
             hs.writelog "COM1", "Setup complete"
    end if
  1. Change the red numbers from 1 to whatever com port you are using.
  2. Add the following lines to your "shutdown.txt" script (again, anywhere before the "end sub"); 
    e=hs.CloseComPort("1")
        if e<> "" then
             hs.writelog "Error closing COM1",e
        else
             hs.writelog "COM1", "Port was closed"
        end if
  1. Shutdown HS and then restart it.  You should see the "COM1   setup complete" message in your log.
  2. Add virtual X-10 devices R1 through Rx (where x is the number of sensors that you have).  Define them as "status only" and create a new device type for them (doesn't matter what you call it).
  3. If you have a humidity sensor connected, create a virtual device R20 for it.  If you have multiple humidity sensors, create multiple virtual devices, starting at R20.
  4. If TEMP05 is connected to the proper COM port, then you should, within a minute (or whatever sampling time you set in TEMP05), start seeing at least one valid temperature in virtual devices R1-x.  If you have all your sensors connected, then all of the virtual devices should be showing valid temperatures.
  5. If you want to generate a web page using these virtual devices, go here.
  6. to download a text version of the com1_event script, go here.

SCRIPT COM1_EVENT.TXT

' this script reads data from TEMP05 v5.00 and stores received sensor readings into HS virtual devices
' Modified 03-01-16 Added Switch Status transfer
' Created by Mitch Matteau 02-12-21
'=============================================================
' HS virtual devices used;
' r1 to r19 for DS18S20 sensors
' r20-29 for humidity sensor
'=============================================================
sub main(data)
'=============================================================
dim i
dim result
dim virt_device
dim default_hc
dim prev_result
dim wind_dirn
dim wind_spd
dim wind_gust
dim high_wind
dim rain_history
dim rain_today
dim rain_absolute
dim SwitchStatus
dim SwitchNumber
dim SwitchBase
' virtual device list
default_hc = "r"
wind_dirn = "z7"
wind_spd = "z4"
wind_gust ="z1"
high_wind = "v6"
rain_history = "v8"
rain_today = "v7"
rain_absolute = "v9"
SwitchBase = "s"
'=============================================================
' Check if the received data is from a temperature reading
'=============================================================
if mid(data,1,4)="Temp" then
sensorid = mid(data,7,2)
if left(sensorid,1) = "0" then
sensorid=mid(sensorid,2,1)
end if
i = Instr(data,"=")
result=trim(mid(data,i+1))
if right(result,1)="F" or right(result,1)="C" then
result = left(result,(len(result)-1))
end if
if CInt(sensorid)<=19 then
virt_device=default_hc+sensorid
prev_result=hs.DeviceString(virt_device)
end if
'=============================================================
' eliminate false readings
' false readings are replaced with the previous reading
'=============================================================
if left(result,3) = "???" then
result = prev_result
end if
if left(result,3) = "185" then '185 is an indicator that the device is not connected
result = prev_result
end if
'=============================================================
' Now save current readings into HomeSeer
'=============================================================
hs.SetDeviceString virt_device,result
if result<>prev_result then
hs.SetDeviceLastChange virt_device, Now()
hs.SetDeviceValue virt_device,result
end if
end if
'=============================================================
' Humidity Sensor Capture
'=============================================================
if left(data,10)="Humidity #" then
i=Instr(data,"#")
sensorid=mid(data,i+1,2)
if left(sensorid,1) = "0" then
sensorid=mid(sensorid,2,1)
end if
virt_device=default_hc+CStr(CInt(sensorid)+19)
prev_result=hs.DeviceString(virt_device)
i = Instr(data,"=")
result = Trim(mid(data,i+1))
if result="???" then
result=prev_result
hs.Writelog "Humidity","Sensor error on #"+sensorid
end if
hs.SetDeviceString virt_device,result
if result<>prev_result then
hs.SetDeviceLastChange virt_device, Now()
end if
end if
'=============================================================
' Version capture
' virtual device z17 used to capture the data
'=============================================================
if mid(data,1,6)="TEMP05" then
version_id = "z17"
hs.SetDeviceString version_id,data
hs.SetDeviceLastChange version_id, Now()
end if
'=============================================================
' Relay Status capture
' virtual devices z31 through z38 used to capture the data
'=============================================================
if mid(data,1,5)="Relay" then
i = Instr(data,"=")
data = mid(data,i+1)
for i=1 to 8
virt_device= "z3"+trim(CStr(i))
a = trim(hs.StringItem(data,i,","))
if a<>hs.DeviceString(virt_device) then
hs.SetDeviceString virt_device,a
hs.SetDeviceLastChange virt_device,Now()
end if
next
end if
'=============================================================
' Wind Direction capture
'=============================================================
if left(data,9)="Wind Dirn" then
result = mid(data,10)
position = InStr(result,"=")
if position<>0 then
a = mid(result,position+1) ' wind direction
if a <>"???" then
hs.SetDeviceString wind_dirn,a
hs.SetDeviceValue wind_dirn,0
end if
end if
end if
'=============================================================
' Wind Speed capture
'=============================================================
If left(data,10)="Wind Speed" Then
result = mid(data,11)
position = InStr(result,"=")
If position<>0 then
result = mid(result,position+1)
a = hs.StringItem(result,1,",") 'wind speed
a = Trim(replace(a,"MPH",""))
If left(a,3)<>"???" then
hs.SetDeviceString wind_spd,a
hs.SetDeviceValue wind_spd,CInt(a)
else
a=0
end if

b = hs.DeviceString(high_wind)
if isnumeric(b) then
b = CInt(hs.DeviceString(high_wind))
else
b = 0
hs.SetDeviceString high_wind,"0"
hs.SetDeviceLastChange high_wind, Now()
end if

if Cint(a) > CInt(b) then
hs.SetDeviceString high_wind,CStr(a)
hs.SetDeviceLastChange high_wind, Now()
hs.WriteLog "HIGH WIND",a+" mph"
hs.CreateVar("HWNDT")
hs.SaveVar "HWNDT",Time()
end if

a = trim(replace(hs.StringItem(result,2,","),"Gust = ",""))
hs.SetDeviceString wind_gust,a
hs.SetDeviceValue wind_gust,CInt(a)
End if
end if
'=============================================================
' Rain Counts
'=============================================================
if Left(data,4)="Rain" Then
position=InStr(data,"=")
If position<>0 then
b = mid(data,position+1) ' rain count
If left(b,3)<>"???" then
b = trim(replace(b," Inch","")) ' remove units
c = hs.DeviceString (rain_history) ' History Info
a = hs.StringItem(c,7,",") ' Yesterday's count
hs.SetDeviceString rain_absolute,b ' absolute rain count
hs.SetDeviceLastChange rain_absolute, Now()
If IsNumeric(b) then
l = CSng(b) ' Value of Absolute count

If Not IsNumeric(a) then
k = l ' on error, assume no count
Else
k = CSng(a) ' Value of Yesterday's count
End If

If (l-k) > 10 then
a = "0.00" ' can't do more than 9 inches in 1 cycle
Else
a = CStr(Round((l-k),2)) ' Result is today's count
End If

If IsNumeric(a) then
hs.SetDeviceString rain_today,a ' Today's count
hs.SetDeviceValue rain_today,CInt(a)
d = ""
For i = 1 to 7
d = d + hs.StringItem(c,i,",")+","
Next
d = d + b
hs.SetDeviceString rain_history,d ' Restore history info
hs.SetDeviceLastChange rain_history, Now()
End If
End If
End If
End If 
End If
'=============================================================
' Switch Status Capture and transfer
'=============================================================
if Left(data,6)="Switch" Then
SwitchNumber = SwitchBase+mid(data,Instr(data,"#")+1,2)
SwitchStatus = mid(data,Instr(data,"=")+1,3)
if left(SwitchStatus,2)="On" then SwitchStatus="On"
hs.execX10 SwitchNumber,SwitchStatus,0
end if
'=============================================================
' use the following to debug your connection to TEMP05...

hs.writelog "TEMP05 RECEIVED",data

end Sub

Return to TEMP05 Project