As if by chance, it works this night in the 2 cases without any need to restart the call...
I added in the 2 cases a fibaro:sleep(5000) after the call, maybe it can have an impact !!!
Case 1: variable to check if I need to restart or not
local sourceTrigger = fibaro:getSourceTrigger();
local currentDate;
local val;
local restart = false;
function tempFunc()
if ((tonumber(os.date("%H%M")) == tonumber(string.format("%02d%02d", "02", "30"))) or (restart == true)) then
fibaro:call(636, "turnOn");
fibaro:debug("TurnOn sent");
fibaro:sleep(5000)
val = fibaro:getValue(636, "value");
if (tonumber(val) == 0) then
restart = true;
fibaro:debug("Failed, I start again");
else
restart = false;
fibaro:debug("Successfull");
end
end
end
if (sourceTrigger["type"] == "autostart") then
while (true) do
tempFunc()
fibaro:sleep(60*1000)
end
end
case 2: lower loop (it works 2 times)
local sourceTrigger = fibaro:getSourceTrigger();
local val;
local restart = false;
function tempFunc()
if (tonumber(os.date("%H%M")) == tonumber(string.format("%02d%02d", "06", "00"))) then
fibaro:call(636, "turnOff");
fibaro:debug("turnOff sent");
fibaro:sleep(5000)
val = fibaro:getValue(636, "value");
if (tonumber(val) == 1) then
restart = true;
fibaro:debug("Failed, I start again");
else
restart = false;
fibaro:debug("Successfull");
end
end
end
if (sourceTrigger["type"] == "autostart") then
while (true) do
tempFunc()
fibaro:sleep(30*1000)
end
end