This is for a Raspberry Pi2 version of the Zee (Zee S2) only.
First, create the following shell script on your Pi2 as user homeseer in your /home/homeseer folder. Name the script getTemp.sh and make sure you assign execute attributes:
Next. create a HomeSeer Virtual device and mark it as Status Only. Click on the Advanced tab to get the device reference number.
Next, create a new Event to run a Script. You can schedule it to run every hour or so. Have the Event run this script. Add your virtual device reference from the step above.
If you find any issues, let me know and I'll update the script in this thread.
Enjoy!
First, create the following shell script on your Pi2 as user homeseer in your /home/homeseer folder. Name the script getTemp.sh and make sure you assign execute attributes:
Code:
homeseer@RPi2 ~ $ cat getTemp.sh #!/bin/bash echo $(/opt/vc/bin/vcgencmd measure_temp) homeseer@RPi2 ~ $ chmod a+x getTemp.sh homeseer@RPi2 ~ $
Next. create a HomeSeer Virtual device and mark it as Status Only. Click on the Advanced tab to get the device reference number.
Next, create a new Event to run a Script. You can schedule it to run every hour or so. Have the Event run this script. Add your virtual device reference from the step above.
Code:
Imports System.IO ''Pi2Temperature.vb - Rob Mason - 7/30/2015 - Free to use/modify. ''This version is for the Pi2 only, and has been tested on Raspbian. Sub Main(parm as object) dim FTemp,CTemp as Double dim proc as System.Diagnostics.Process dim resp,t,s() as String dim sw as StreamWriter dim dref as Integer = 866 'use your own virtual device reference Try proc = new System.Diagnostics.Process() proc.StartInfo.FileName="/home/homeseer/getTemp.sh" proc.StartInfo.UseShellExecute=False proc.StartInfo.RedirectStandardOutput = True proc.Start() t=proc.StandardOutput.ReadToEnd() s = Split(t,"=") resp=s(1) s=split(resp,"'") resp=s(0) CTemp = CDbl(resp) FTemp = getFarenheit(CTemp) hs.WriteLog("Pi2Temperature","CTemp=[" & CTemp & "] FTemp=[" & FTemp & "]") ''optionally write the values to a file here sw = new StreamWriter("Data/Pi2Temperature.log",True) sw.writeLine(Now() & " -- " & CTemp & " - " & FTemp) ''update HomeSeer device here - use CTemp or FTemp as needed hs.SetDeviceValueByRef(dref, FTemp, True) hs.SetDeviceString(dref, "Pi2 Current Temp: " & FTemp.ToString("0.#") & "° F", True) Catch ex as Exception hs.WriteLog("Pi2Temperature Error t=[" & t & "]",ex.Message) Finally if(not sw is Nothing) then sw.Close resp=Nothing End Try End Sub Public Function getFarenheit(ByVal c as Double) as Double dim d as Double d = c*9/5+32 return d End Function
Enjoy!
Comment