Kör senaste betan sen några dagar......kan det vara den som spökar?
[ERROR] 15:57:17: line 22: bad argument #1 to 'sub' (string expected, got nil)
Code: Select all
--[[
%% properties
%% autostart
%% globals
--]]
local device = 4;
local lightsOutWeekday = "22:10";
local lightsOutWeekend = "00:30";
local sunsetOffset = -30;
local lightsOn;
local lightsOut;
local now = os.date("*t");
lightsOutWeekday = string.sub(lightsOutWeekday,1,2) * 60 + string.sub(lightsOutWeekday,4,5)
lightsOutWeekend = string.sub(lightsOutWeekend,1,2) * 60 + string.sub(lightsOutWeekend,4,5)
while true do
now = os.date("*t");
time = string.format("%02d", now.hour) * 60 + string.format("%02d", now.min);
lightsOn = fibaro:getValue(1, "sunsetHour");
lightsOn = string.sub(lightsOn,1,2) * 60 + string.sub(lightsOn,4,5);
lightsOn = lightsOn + sunsetOffset;
if (now.wday <= 5) then
lightsOut = lightsOutWeekday;
else
lightsOut = lightsOutWeekend;
end
if (((lightsOut < 720) or (lightsOn < lightsOut)) and (time == lightsOn)) then
fibaro:call(4, "turnOn");
fibaro:sleep(math.random(2000,6000));
fibaro:call(5, "turnOn");
fibaro:sleep(math.random(8000,12000));
fibaro:call(6, "turnOn");
fibaro:sleep(math.random(1000,4000));
fibaro:call(8, "turnOn");
fibaro:sleep(math.random(8000,12000));
fibaro:call(9, "turnOn");
fibaro:sleep(math.random(8000,9000));
fibaro:call(11, "turnOn");
fibaro:sleep(math.random(8000,12000));
fibaro:call(151, "turnOn");
fibaro:sleep(math.random(2000,6000));
fibaro:call(7, "turnOn");
while (time ~= lightsOut) do
now = os.date("*t");
time = string.format("%02d", now.hour) * 60 + string.format("%02d", now.min);
fibaro:sleep(55*1000);
end
fibaro:call(device, "turnOff");
end
fibaro:sleep(55*1000);
end