
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 v4.25 or lower. If you have v5.00 or higher, a new script page is available here.
Note 4: An alternative script is available (modified by Frank J. Perricone <hawthorn@starband.net>) lets you put an icon into the device string. You will find it here.
' this script reads data from TEMP05 and stores received temperatures into HS virtual devices
' Created by Mitch Matteau 00-01-15
' Modified 01-11-25: added DeviceValue saving of temperature results
' Modified 01-09-16 : added capture of relay status, rain counts, wind speed,
wind direction and TEMP05 version #
' Modified 01-08-25 : added conditional update of DeviceLastChange and removed
restriction for V4.16 or greater firmware
' Modified 01-08-21 : changed to add use of hs.SetDeviceLastChange to record changes
' Modified 01-07-04 : added support for OWWS (V1 or V2) users
' Modified 01-04-02 : added support for 1 humidity sensor
' Modified 01-05-06 : added SetDeviceValue output of temperatures
' Modified 01-05-27 : added support for multiple humidity sensors
'=============================================================
' 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 prev_result
'=============================================================
' Check if the received data is from a temperature reading
'=============================================================
if mid(data,1,6)="Sensor" then
sensorid = mid(data,9,2)
if left(sensorid,1) = "0" then
sensorid=mid(sensorid,2,1)
end if
' the following line is only required for V4.16 or lower firmware OR if you are not using a V1 Weather Station
' if sensorid="0" then sensorid = "30" ' needed for the zero'th sensor
'
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="r"+sensorid '"r" is the house code for the virtual device used
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 v4.12 or v4.13 software only
'=============================================================
if left(data,11)="Humidity = " then
prev_result=hs.DeviceString("r20")
result = Trim(mid(data,11))
if result="???" then
result=prev_result
hs.Writelog "Humidity","Sensor error"
end if
hs.SetDeviceString "r20",result
if result<>prev_result then
hs.SetDeviceLastChange "r20", Now()
end if
end if
'=============================================================
' Humidity Sensor Capture v4.14, or higher, software only
'=============================================================
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="r"+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
'=============================================================
end sub
' 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 and Rain Information capture
'=============================================================
if left(data,5)="=====" then
dim wind_dirn
dim wind_spd
dim wind_gust
dim high_wind
' virtual device list
wind_dirn = "z7"
wind_spd = "z4"
wind_gust ="z1"
high_wind = "v6"
result = mid(data,6)
a = trim(hs.StringItem(result,1,","))
' wind direction
if a <>"???" then
hs.SetDeviceString
wind_dirn,a
hs.SetDeviceValue
wind_dirn,0
end if
a = hs.StringItem(result,2,",")
'wind speed
a = trim(left(a,len(a)-3))
if left(a,2)<>"??" 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 = hs.StringItem(result,3,",") ' wind gust
a = trim(left(a,len(a)-3))
hs.SetDeviceString wind_gust,a
hs.SetDeviceValue wind_gust,CInt(a)
'=============================================================
' Rain Counts
'=============================================================
dim rain_history
dim rain_today
dim rain_absolute
rain_history = "v8"
rain_today = "v7"
rain_absolute = "v9"
b = hs.StringItem(result,4,",") ' rain count
if len(b)>2 then
b = trim(left(b,len(b)-2)) ' remove units
c = hs.DeviceString (rain_history) ' History Info
a = hs.StringItem(c,7,",") ' Yesterday's count
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
end if
end if
if IsNumeric(a) then
hs.SetDeviceString
rain_absolute,b ' absolute rain count
hs.SetDeviceLastChange
rain_absolute, Now()
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