Announcement

Collapse
No announcement yet.

Zee Script to monitor temperature

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Zee Script to monitor temperature

    How about a Zee Script to monitor your operating temperature? Here's something I threw together this morning:

    Create a virtual device:
    Name: Zee Temperature
    Address: zeetemp
    Status-Only Device
    On the Status Graphic tab, delete the status text and graphics - not needed.
    Note the Reference ID on the Advanced tab - you'll need it below
    Save the device by clicking Done

    Create a recurring event:
    Update Zee Temperature
    Mine is set to run every 15 mins:
    Run a Script or Script Command
    (make sure you are in Advanced Editing Mode)
    Click "Edit" for the Script File
    On the dialog that comes up, enter the script:
    /usr/local/HomeSeer/scripts/ZeeTemperature.vb

    Copy and Paste this script into the Script box:
    PHP Code:
    Imports System.IO

    ''ZeeTemperature.vb Rob Mason 10/23/2013 Free to use/modify.

    Sub Main(parm as object)
       
    dim FTemp,CTemp as Double
       dim lin 
    as String
       dim sr 
    as StreamReader
       dim dref 
    as Integer 671     'use your own device reference

       Try
          sr = new StreamReader("/sys/class/thermal/thermal_zone0/temp")
          lin=sr.ReadLine()

          CTemp = CDbl(lin)/1000.0
          FTemp = getFarenheit(CTemp)
    ''hs.WriteLog("ZeeTemperature","lin=" & lin & "-- CTemp=" & CTemp & "  FTemp=" & FTemp)

    ''update device here - use CTemp or FTemp as needed
          hs.SetDeviceValueByRef(dref, FTemp, True)
          hs.SetDeviceString(dref, "Current Temp: " & FTemp.ToString("0.#") & "&deg F", True)

       Catch ex as Exception
          hs.WriteLog("ZeeTemperature",ex.Message)
       Finally
          if(not sr is Nothing) then sr.close()
       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 
    Change the device reference to your device's reference from the device creation above.

    Save the script.
    Monitor your logs to make sure there are no errors.
    Monitor your virtual device for regular temperature updates.
    Attached Files
    HS4Pro on a Raspberry Pi4
    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

    HSTouch Clients: 1 Android

    #2
    Thanks for posting... I am new at this. How do you create a virtual device in HS3? I don't see an option for that when adding the new device...

    Thanks
    andy

    Comment


      #3
      +1 on the above. I'm also trying to setup the Zee temperature script.

      I can't seem to find any info on creating virtual devices in HS3.

      Thanks for any info.

      Comment


        #4
        Sure! To add a device - virtual or any other type, just click the "Add Device" button in the upper-right corner of the Device Management screen:

        Name: Zee Temperature
        Address: zeetemp
        Status-Only Device
        On the Status Graphic tab, delete the status text and graphics - not needed.
        Note the Reference ID on the Advanced tab - you'll need it below
        Save the device by clicking Done
        Attached Files
        HS4Pro on a Raspberry Pi4
        54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
        Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

        HSTouch Clients: 1 Android

        Comment


          #5
          Thank-you Rob for providing us this script to run on the Zee.
          - Pete

          Auto mator
          Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
          Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
          HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

          HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
          HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

          X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

          Comment


            #6
            Thanks... I got it working.

            I see something a bit odd. If I close out the browser and reopen HS3, the temperature and time updated is the same as the one when I last closed HS3 (not the most recent temp measurement). The log still shows the event running... no errors, just that the Device Managment screens are not getting updated.

            Anyone else see that?

            Comment


              #7
              Originally posted by Pete View Post
              Thank-you Rob for providing us this script to run on the Zee.
              Thanks Pete! There's all kinds of linux goodies on that Zee!
              HS4Pro on a Raspberry Pi4
              54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
              Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

              HSTouch Clients: 1 Android

              Comment


                #8
                Originally posted by expo View Post
                Thanks... I got it working.

                I see something a bit odd. If I close out the browser and reopen HS3, the temperature and time updated is the same as the one when I last closed HS3 (not the most recent temp measurement). The log still shows the event running... no errors, just that the Device Managment screens are not getting updated.

                Anyone else see that?
                Make sure you're running Chrome or IE with Compatibility Mode toggled.
                Also, make sure there are no errors in the error log...
                HS4Pro on a Raspberry Pi4
                54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                HSTouch Clients: 1 Android

                Comment


                  #9
                  Pushing it a bit yesterday installed Webmin. It did update some 40 packages.

                  I was going to do some granular metrics with it (but then again pushing it a bit).
                  Attached Files
                  - Pete

                  Auto mator
                  Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
                  Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
                  HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

                  HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
                  HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

                  X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

                  Comment


                    #10

                    Comment


                      #11
                      It's not ambient temperature, its the temperature of the processor core.

                      Sent from my Xoom using Tapatalk
                      HS4Pro on a Raspberry Pi4
                      54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                      Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                      HSTouch Clients: 1 Android

                      Comment


                        #12
                        Thank you Rob for providing this script!

                        Here using a USB Maxim Mini two 1-wire port (with multiple sensors) connected to the RPi2 in the attic. This provides attic ambient temperature and humidity today.



                        You can also install a mini RTC clock with one 1-Wire temperature sensor on the RPi2. This would provide an internal RPi2 case temperature.

                        This triggers every 5 minutes via a HS3 event and updates the variables. Personally here it is separate from reading the 1-Wire temperatures using DigiTemp which is a bit different than Rob's script above. I switched the DigiTemp values to running in a Cron job.

                        I am also SSH'ing the DigiTemp values to a second Homeseer 3 box. There is another copy of Rob's script which reads the values and posts.

                        RPi2 Cron Job ==> (sort of one liner) which occurs

                        cd /root;/usr/bin/digitemp_DS9097U -a -q >temp;cat temp | ssh root@ipofHS3ProBox "cat > /root/temp.txt"

                        I touched up Rob's script here (there is another script that Rob wrote for the Digitemp stuff) which is an earlier version of the above script to show temperature degrees, Farenheit and percentage of relative humidity. Note that this is a different script that uses Digitemp and a 1-Wire 9097 USB device.

                        
                        Code:
                        Imports System.IO
                        ''1WireTemp.vb - Rob Mason - 7/30/2015 - Free to use/modify. 
                        ''reads in the content of a temp file created by the 1-wire.
                        Sub Main(parm as object) 
                           dim FTemp,CTemp,Humid as Short
                           dim lin,t,h,x,n,s() as String 
                           dim sr as StreamReader 
                           dim sensor0_Temp_Ref as Integer = 260        'use your own device references 
                           dim sensor1_Temp_Ref as Integer = 261 
                           dim sensor1_Humid_Ref as Integer = 262
                           
                           Try 
                              sr = new StreamReader("/root/temp")       ''point this to your temp file
                                while(1) 
                                        lin=sr.ReadLine() 
                                        if(lin is nothing) then exit while
                                        if(lin.length()<=0) then exit while
                                        s = Split(lin,"Sensor ") 
                                        t = s(1) 
                                        n = left(t,t.indexOf(" ")).Trim ''contains sensor number
                                        s = Split(t,"C: ") 
                                        CTemp = CDBL(left(s(1),s(1).indexOf(" ")).Trim) 
                                        FTemp = getFarenheit(CTemp) 
                                        s = Split(t,"H: ") 
                                        if(s.length>1) then 
                                                Humid=CDBL(left(s(1),s(1).indexOf("%")).Trim) 
                                        else 
                                                Humid=0 
                                        end if
                                      ''hs.writeLog("debug","t=[" & t & "]  n=[" & n & "] CTemp=[" & CTemp & "] FTemp=[" & FTemp & "] Humid=[" & Humid & "]")
                                        Select case n 
                                                case 0 
                                                ''update HomeSeer here with the device references above 
                                                hs.setDeviceValueByRef(sensor0_Temp_Ref,FTemp,True)     ''change to CTemp if you want Celsius 
                                                hs.setDeviceLastChange(sensor0_Temp_Ref,Now()) 
                                                hs.setDeviceString(sensor0_Temp_Ref,FTemp &" "&chr(176)&"F",False) 
                                                case 1 
                                                hs.setDeviceValueByRef(sensor1_Temp_Ref,FTemp,True)     ''change to CTemp if you want Celsius 
                                                hs.setDeviceLastChange(sensor1_Temp_Ref,Now()) 
                                                hs.setDeviceString(sensor1_Temp_Ref,FTemp & " "&chr(176)&"F",False)
                                                if(humid>0) then 
                                                        hs.setDeviceValueByRef(sensor1_Humid_Ref,humid,True)    ''change to CTemp if you want Celsius
                                                        hs.setDeviceLastChange(sensor1_Humid_Ref,Now()) 
                                                        hs.setDeviceString(sensor1_Humid_Ref,humid & "% RH",False) 
                                                end if
                                        End Select 
                                End While
                        
                        
                           Catch ex as Exception 
                              hs.WriteLog("1WireTemp Error","lin=[" & lin & "]    " & ex.Message) 
                           Finally 
                              if(not sr is Nothing) then sr.close() 
                           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
                        To read the CPU temperature values you just need to see the following stuff. Here I put it in the SSH login script.

                        Code:
                        # Core Temperature
                        coretemp=$(vcgencmd measure_temp | grep -o '[0-9.]*')
                        echo "Core Temperature:" "$coretemp" "C"
                        To get CPU temperatures in Fahrenheit you can run this script. IE: just echo > this script to a file called CPU.txt if you want. This is different and a manual means.

                        Code:
                        #!/bin/bash
                        ######################################################################
                        # Raspberry Pi
                        #
                        # Gross Script by Dweeber (Kevin Reed) <dweeber.dweebs@gmail.com>
                        # V1.0 2012-09-19
                        #
                        # Use the vcgencmd to obtain the Temp of the SOC
                        # then calculates the F value using bc.
                        #
                        # Requires bc to be loaded. If not then
                        # apt-get install bc
                        #
                        ######################################################################
                        tm=`/opt/vc/bin/vcgencmd measure_temp`
                        tc=`echo $tm| cut -d '=' -f2 | sed 's/..$//'`
                        tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc)
                        echo temp = $tf\'F \($tc\'C\)
                        Attached Files
                        Last edited by Pete; April 13, 2016, 06:48 AM.
                        - Pete

                        Auto mator
                        Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
                        Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
                        HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

                        HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
                        HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

                        X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

                        Comment


                          #13
                          Thanks for sharing Rob!!


                          Sent from my iPhone
                          Tom
                          baby steps...starting again with HS3
                          HS3Pro: Z-NET & 80 Z wave Devices,
                          HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
                          Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
                          In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
                          System: XP on Fanless Mini-ITX w/ SSD

                          Comment


                            #14
                            Can this script be modified for the SEL? If so, how?

                            I've installed this as is, but it's returning an incorrect reading of around 80F.

                            Comment


                              #15
                              Rob's original HS3 script reads the core temperature of the RPi2 which is a text file.

                              I installed DigiTemp on my original RPi2 here and modded Rob's script to read the Digitemp text file of temps and humidity.

                              Please note old Zee-2 RPi2 is no longer running HS3. Rather it is just a slave to the HS3 lite and HS3 Pro box.

                              It was originally a DIY with a PiFace RTC and ZWave dot me GPIO card and POE powered in the attic. Today it is running Jessie and serving up Z-Wave to HS3.
                              (and X10/UPB and a Digitemp 1-wire network).

                              Both HS3 boxes today just read the text from the original RPi2 and use Rob's script to create variables every few minutes.
                              Last edited by Pete; November 19, 2016, 11:03 AM.
                              - Pete

                              Auto mator
                              Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
                              Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
                              HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

                              HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
                              HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

                              X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

                              Comment

                              Working...
                              X