This is an old revision of the document!


3- Liste des scripts LUA


1- Modifier la couleur d’une lumière Led en fonction de la température de la pièce

By captainigloo

But : Script permettant de modifier la couleur d’une led RGB en fonction de la température de la pièce

-- Title: Set RGB light output depending on Temperature
-- 
-- Description :
-- Set white color if temp is < 10°C
-- Set light blue color if temps is between 10 and 15
-- Set dark blue color if temp is between 15 and 19
-- Set green color if temp is between 19 and 22
-- Set Yellow color ir temp is between 22 and 25
-- Set Orange color if temp is between 25 and 28
-- Set Red color if temp is greater than 28
--
-- Inputs 
--   * input_4 : N° entrée Temperature
-- Output
--   * output_6 : N° Sortie RGB light
-- Events
-- This script may be launched on input_4 changes

local temp = calaos:getInputValue("input_4")
if temp < 10.0 then
    --blanc
    str = "set 0x60FFFF"
elseif temp >= 10.0 and temp < 15.0 then
    --bleu clair
    str = "set 0x28FFFF"
elseif temp >= 15.0 and temp < 19.0 then
    --bleu foncé
    str = "set 0x0060FF"
elseif temp >= 19.0 and temp < 22.0 then
    -- vert
    str = "set 0x28FF28"
elseif temp >= 22.0 and temp < 25.0 then
    -- Jaune
    str = "set 0x7AFF00"
elseif temp >= 25.0 and temp < 28.0 then
    -- Orange
    str = "set 0xFFFF00"
elseif temp > 28.0 then
    -- Rouge
    str = "set 0xFF3D00"
end
calaos:setOutputValue("output_6", str)
return true


2- Envoyer un SMS via Free suivant un évènement donné

By captainigloo

But : Script permettant d’envoyer un message par SMS en fonction d’une condition. Attention ne fonctionne qu’avec free. Voir le tuto complet ici : Utilisation du systeme de notifications par sms de free

function urlencode(str)
   if (str) then
      str = string.gsub (str, "\n", "\r\n")
      str = string.gsub (str, "([^%w ])",
         function (c) return string.format ("%%%02X", string.byte(c)) end)
      str = string.gsub (str, " ", "%%20")
   end
   return str    
end

local user = "username"
local pass = "password"
local msg = "le message à envoyer en fonction de la règle"

calaos:requestUrl("https://smsapi.free-mobile.fr/sendmsg?user="..user.."&pass="..pass.."&msg="..urlencode(msg))

return true