I’m kind of a control freak when it comes to my servers, lately the temperatures in Sweden reaches well above 30 degrees celsius and i need to get a warning in case the temp goes below 23 or above 26.

I use the following setup, it does a lot more than just temperature control like sending SMS when ever the magnetic lock gets activated on non-office-hours and sends an email with a picture of the person entering.

  • RFXtrx433XL USB-controller
    for sending and receiving signals wireless over the 433Mhz band.
  • Telldus Thermo/Hygro sensor
    433Mhz Thermometer
  • Raspberry PI 4B, 4GB

Get Raspbian on your SD-Card and then use the following guide to install Domoticz:

https://www.domoticz.com/wiki/Raspberry_Pi

Create a LUA script

In the Domoticz menu, head over to:
Setup -> More Options -> Events
Select new LUA script and choose DEVICE as trigger.

This is my first ever LUA script, there are probably better ways of doing this but it works for now.

-- Warn on warm or cold temperature in Serverskåp 1

local kallt = 23
local varmt = 26

commandArray = {}

-- loop through all the changed devices
for deviceName,deviceValue in pairs(devicechanged) do

    if (deviceName == 'Serverskåp 1_Temperature') then

        print("*** Serverskåp1 Temp ("..tostring(deviceValue)..")" )

        if deviceValue < kallt  then

            print("*** Serverskåp1 Temp LOW! ("..tostring(deviceValue)..")" )
            -- os.execute ('/bin/echo "Serverskåp1 Temp! ('..tostring(deviceValue)..')" | /usr/bin/mail -s "[Warn] Serverskåp1 Låg Temp" root')
            os.execute ("/usr/bin/curl 'http://sms.asbra.lan/index.php?phone=%2B46720437670&message=Temp+Low+"..tostring(deviceValue).."' &> /dev/null")

        elseif deviceValue > varmt then

            print("*** Serverskåp Temp HIGH!("..tostring(deviceValue)..")")
            -- os.execute ('/bin/echo "Serverskåp1 Temp! ('..tostring(deviceValue)..')" | /usr/bin/mail -s "[Warn] Serverskåp1 Låg Temp" root')
            os.execute ("/usr/bin/curl 'http://sms.asbra.lan/index.php?phone=%2B46720437670&message=Temp+High+"..tostring(deviceValue).."' &> /dev/null")

        end
    end
end

return commandArray 

Published by Nimpen J. Nordström

System Developer and Network Security Enthusiast