Voilàcomment je vois les choses.
--[[
%% properties
169 value
%% globals
--]]
local currentDate = os.date("*t");
local TriggerTime = string.format("%02d",currentDate.hour)..":"..string.format("%02d",currentDate.min)..":"..string.format("%02d",currentDate.sec);
time = fibaro:getGlobalValue("CTime");
fibaro:debug(time);
if (tonumber(time) == 0) then
-- la première foi la variable Ctime est à0
fibaro:setGlobal("CTime", TriggerTime);
fibaro:abort();
end
_, _, h1, m1, s1 = string.find(time, "(%d+)%d+)%d+)")
_, _, h2, m2, s2 = string.find(TriggerTime, "(%d+)%d+)%d+)")
dh = h2-h1;
if (dh < 0) then dh = dh + 24; end
dm = m2-m1;
if (dm < 0) then dm = dm + 60; end
ds = s2-s1;
if (ds < 0) then ds = ds + 60; end
local status = fibaro:getValue(169, "value");
if (status == "1") then
-- le Device pass de off àon
-- le temps correspond àun temps d'arrêt
fibaro:debug("arret pendant :"..dh.." h "..dm.." m "..ds.." s");
else
-- le device passe de on àoff
-- le temps calculé correspond àun temps de marche
fibaro:debug("marche pendant :"..dh.." h "..dm.." m "..ds.." s");
end
fibaro:setGlobal("CTime", TriggerTime);
Il faut créer une variable CTime.
Tu peux mettre plusieurs triggers et utiliser json pour gérer plusieurs devices avec la même scène et la même variable.
A toi de voir ce que tu fais avec les temps calculés.