Code : Tout sélectionner
function makeVar(name,value)
if uservariables[name]==nil then
local url = 'curl '..domoticzURL..'/json.htm?type=command¶m=saveuservariable&vname='..url_encode(name)..'&vtype=2&vvalue='..url_encode(value)
os.capture(url, false)
else
local url = 'curl '..domoticzURL..'/json.htm?type=command¶m=updateuservariable&vname='..url_encode(name)..'&vtype=2&vvalue='..url_encode(value)
os.capture(url, false)
end
endCode : Tout sélectionner
function log(txt,lvl)
if lvl==nil then
print("<font color='green'>" .. script .. ' ' .. txt .. "</font>")
elseif lvl>=3 then
error(script .. ' ' .. txt)
else
if lvl<=debug then
if lvl==1 then
print("<font color='yellow'>" .. script .. ' ' .. txt .. "</font>")
elseif lvl==2 then
print("<font color='red'>" .. script .. ' ' .. txt .. "</font>")
end
end
end
endet chaques log avec son propre niveau. Un niveau superieur ou egale a 3 pour afficher un erreure systematique, ou sans niveau pour afficher un log systematique.
Le niveau 1 me sert pour des infos et le niveau 2 me sert pour les retours de commande en general.