LUA, send email when Temperature is high



  • I am using this script to detect if the drawer is open for my "TV-electronics". My kids start PS3 but forget to open the drawer. That's why I made this 🙂

    Create a user variable named "AppleTVVarm", of course you can name it to what you like but use my names first then after you tested it and it works you can change the names. Device name must be change to your device name If variable is 1 it means that the temperature has reached its limit.
    If the temperature get above 35 it will send me an email and when it goes below 30 it will send a new email, so I know it gets cooled down.
    Varm means Warm
    Sval means cool

    commandArray = {}
    
    local function update(cmd)
    if devicechanged[cmd] then
        local vari = "Variable:"  .. cmd .. "Varm" --add Varibale: before device and Varm after device
        local varm = cmd .. "Varm" --add Varm after device
        --print(cmd)
        --print(varm)
        --print(vari)
    
        temperature = tonumber(devicechanged[''..cmd..'_Temperature']) --read temperature from device, if device have more than only temperature
        if (temperature > 35) and (uservariables[varm] == 0) then --if temperature is above 35 for the first time
            commandArray['SendEmail']=''..cmd..' varm#""#abc@hotmail.com' --send email
            commandArray[vari] = "1" --set variable to 1
        end
        if (temperature < 30) and (uservariables[varm] == 1) then --if temperature is below 30
            commandArray['SendEmail']=''..cmd..' sval#""#abc@hotmail.com' --send email
            commandArray[vari] = "0" --set variable to 0
        end
    end
    
    end
    
    update ('AppleTV') --device to read temperature from
    update ('PS3')
    update ('Stereo')
    
    return commandArray
    

    copy the code and create a new script in Domoticz, select LUA and Device otherwise it will not work


 

399
Online

8.0k
Users

8.8k
Topics

94.3k
Posts