Code: Select all
--[[
%% autostart
%% properties
%% globals
Hemma
--]]
--local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
local currentDate = os.date("*t");
--local startSource = fibaro:getSourceTrigger();
if (
( tonumber(fibaro:getGlobalValue("Hemma")) == tonumber("1") )
and
( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and os.date("%H:%M", os.time()+60*60) == fibaro:getValue(1, "sunsetHour")) )
or
( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "06:30") )
)
then
fibaro:call(33, "turnOn");
fibaro:call(106, "turnOn");
fibaro:call(119, "turnOn");
fibaro:call(120, "turnOn");
fibaro:call(186, "turnOn");
else if (
( tonumber(fibaro:getGlobalValue("Hemma")) == tonumber("0") )
)
then
fibaro:call(33, "turnOff");
fibaro:call(106, "turnOff");
fibaro:call(119, "turnOff");
fibaro:call(120, "turnOff");
fibaro:call(186, "turnOff");
else if (
( tonumber(fibaro:getGlobalValue("Hemma")) == tonumber("1") )
and
( ((currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "23:00") )
or
( ((currentDate.wday == 1 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "00:00")
or ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and os.date("%H:%M", os.time()-60*60) == fibaro:getValue(1, "sunriseHour")) )
)
then
fibaro:call(33, "turnOff");
fibaro:call(106, "turnOff");
fibaro:call(119, "turnOff");
fibaro:call(120, "turnOff");
fibaro:call(186, "turnOff");
end
end
end
setTimeout(tempFunc, 60*1000)
end