Re: Arbetsdag idag / imorgon - Hur man räknar ut Påsken varj
Posted: 21 Apr 2014, 09:19
if WorkDay(os.date("*t")) then
[ERROR] 09:15:55: line 119: 'then' expected near 'if'
[ERROR] 09:15:55: line 119: 'then' expected near 'if'
Allt inom Z-wave och IoT
https://zwaveforum.se/
Hmm två slarvfel - sorry det var inte meningen. Båda rättade. Btw observera att jag har lagt in två lediga dagar i Maj - du kanske är ledig också?Johan71 wrote:if WorkDay(os.date("*t")) then
[ERROR] 09:15:55: line 119: 'then' expected near 'if'
Code: Select all
--[[
%% properties
%% globals
--]]
function Vacation_Days(dateForCheck)
-- Ange vilka datum som skall anses som lediga datum
local LedigaDatum = { "2014-05-02" , "2014-05-30" }
local datum
for z,datum in pairs(LedigaDatum) do
TestDatum = os.date("*t", os.time({year = tonumber(string.sub(datum,1,4)), month = tonumber(string.sub(datum,6,7)), day = tonumber(string.sub(datum,9))}))
if ( TestDatum.year == dateForCheck.year and TestDatum.month == dateForCheck.month and TestDatum.day == dateForCheck.day ) then
return true
end
end
return false
end
function Holidays_CalculateEaster(year)
golden = (year % 19) + 1
c = math.floor(year/400) + math.floor(8*(math.floor(year/100)+11)/25) - math.floor(year/100)
s = (11 * golden + c) % 30
if (s < 0) then
s = s + 30
end
pfm = os.time{year=year, month=4, day=19} - s * 24 * 60 * 60
if (pfm == os.time{year=year, month=4, day=19}) then
pfm = pfm - 24 * 60 * 60
elseif (pfm == os.time{year=year, month=4, day=18} and golden > 11) then
pfm = pfm - 24 * 60 * 60
end
sunday = pfm + (7 - tonumber(os.date("%w", pfm))) * 24 * 60 * 60
friday = sunday - 2 * 24 * 60 * 60
return {year, tonumber(os.date("%m", friday)), tonumber(os.date("%d", friday))}
end
function WorkDay(dateToCheck)
local easterDay
local returnValue
returnValue = true
-- Indatum är en lördag eller Söndag
if ( dateToCheck.wday == 1 or dateToCheck.wday == 7 ) then
returnValue = false
-- Indatum är nationaldag
elseif ( dateToCheck.month == 6 and dateToCheck.day == 6 ) then
returnValue = false
-- Indatum är Nyårsdag eller trettondag
elseif ( dateToCheck.month == 1 and (dateToCheck.day == 1 or dateToCheck.day == 6 ) ) then
returnValue = false
-- Indatum är 1:a maj
elseif ( dateToCheck.month == 5 and dateToCheck.day == 1 ) then
returnValue = false
-- Indatum är Julafton,Juldag, Annandag eller Nyårsafton
elseif ( dateToCheck.month == 12 and (dateToCheck.day == 24 or dateToCheck.day == 25 or dateToCheck.day == 26 or dateToCheck.day == 31) ) then
returnValue = false
end
-- Långfredag
easterDay = Holidays_CalculateEaster(dateToCheck.year)
if ( easterDay[1] == dateToCheck.year and easterDay[2] == dateToCheck.month and easterDay[3] == dateToCheck.day ) then
returnValue = false
end
-- AnnandagPåsk
easterDay2 = os.date("*t", os.time({year = easterDay[1], month = easterDay[2], day = easterDay[3]})+3*24*60*60)
if ( easterDay2.year == dateToCheck.year and easterDay2.month == dateToCheck.month and easterDay2.day == dateToCheck.day ) then
returnValue = false
end
-- Kristihimmelfärdsdag? +41 dagar från Långfredag?
datum3 = os.date("*t", os.time({year = easterDay[1], month = easterDay[2], day = easterDay[3]})+41*24*60*60)
if ( datum3.year == dateToCheck.year and datum3.month == dateToCheck.month and datum3.day == dateToCheck.day ) then
returnValue = false
end
-- hitta midsommardagen för att kunna kontrollera midsommarafton
-- midsommardagen = den lördag som infaller under tiden den 20-26 juni -> midsommarafton bör vara den fredag som inträffar under tiden 19-25 juni
if ( dateToCheck.month == 6 and (dateToCheck.day >= 19 and dateToCheck.day <= 25) and dateToCheck.wday == 6 ) then
returnValue = false
end
if ( Vacation_Days(dateToCheck) ) then
returnValue = false
end
return returnValue
end
if WorkDay(os.date("*t")) then
fibaro:setGlobal("WorkToday","True");
else
fibaro:setGlobal("WorkToday","False");
end
if WorkDay(os.date("*t", os.time()+24*60*60)) then
fibaro:setGlobal("WorkTomorrow","True");
else
fibaro:setGlobal("WorkTomorrow","False");
end
Code: Select all
--[[
%% autostart
%% properties
%% globals
--]]
function Vacation_Days(dateForCheck)
-- Ange vilka datum som skall anses som lediga datum
local LedigaDatum = { "2014-05-02" , "2014-05-30" }
local datum
for z,datum in pairs(LedigaDatum)
do
TestDatum = os.date("*t", os.time({year = tonumber(string.sub(datum,1,4)), month = tonumber(string.sub(datum,6,7)), day = tonumber(string.sub(datum,9))}))
if ( TestDatum.year == dateForCheck.year and TestDatum.month == dateForCheck.month and TestDatum.day == dateForCheck.day ) then
return true
end
end
return false
end
function Holidays_CalculateEaster(year)
golden = (year % 19) + 1
c = math.floor(year/400) + math.floor(8*(math.floor(year/100)+11)/25) - math.floor(year/100)
s = (11 * golden + c) % 30
if (s < 0) then
s = s + 30
end
pfm = os.time{year=year, month=4, day=19} - s * 24 * 60 * 60
if (pfm == os.time{year=year, month=4, day=19}) then
pfm = pfm - 24 * 60 * 60
elseif (pfm == os.time{year=year, month=4, day=18} and golden > 11) then
pfm = pfm - 24 * 60 * 60
end
sunday = pfm + (7 - tonumber(os.date("%w", pfm))) * 24 * 60 * 60
friday = sunday - 2 * 24 * 60 * 60
return {year, tonumber(os.date("%m", friday)), tonumber(os.date("%d", friday))}
end
function WorkDay(dateToCheck)
local easterDay
local returnValue
returnValue = true
-- Indatum är en lördag eller Söndag
if ( dateToCheck.wday == 1 or dateToCheck.wday == 7 ) then
returnValue = false
-- Indatum är nationaldag
elseif ( dateToCheck.month == 6 and dateToCheck.day == 6 ) then
returnValue = false
-- Indatum är Nyårsdag eller trettondag
elseif ( dateToCheck.month == 1 and (dateToCheck.day == 1 or dateToCheck.day == 6 ) ) then
returnValue = false
-- Indatum är 1:a maj
elseif ( dateToCheck.month == 5 and dateToCheck.day == 1 ) then
returnValue = false
-- Indatum är Julafton,Juldag, Annandag eller Nyårsafton
elseif ( dateToCheck.month == 12 and (dateToCheck.day == 24 or dateToCheck.day == 25 or dateToCheck.day == 26 or dateToCheck.day == 31) ) then
returnValue = false
end
-- Långfredag
easterDay = Holidays_CalculateEaster(dateToCheck.year)
if ( easterDay[1] == dateToCheck.year and easterDay[2] == dateToCheck.month and easterDay[3] == dateToCheck.day ) then
returnValue = false
end
-- AnnandagPåsk
easterDay2 = os.date("*t", os.time({year = easterDay[1], month = easterDay[2], day = easterDay[3]})+3*24*60*60)
if ( easterDay2.year == dateToCheck.year and easterDay2.month == dateToCheck.month and easterDay2.day == dateToCheck.day ) then
returnValue = false
end
-- Kristihimmelfärdsdag? +41 dagar från Långfredag?
datum3 = os.date("*t", os.time({year = easterDay[1], month = easterDay[2], day = easterDay[3]})+41*24*60*60)
if ( datum3.year == dateToCheck.year and datum3.month == dateToCheck.month and datum3.day == dateToCheck.day ) then
returnValue = false
end
-- hitta midsommardagen för att kunna kontrollera midsommarafton
-- midsommardagen = den lördag som infaller under tiden den 20-26 juni -> midsommarafton bör vara den fredag som inträffar under tiden 19-25 juni
if ( dateToCheck.month == 6 and (dateToCheck.day >= 19 and dateToCheck.day <= 25) and dateToCheck.wday == 6 ) then
returnValue = false
end
if ( Vacation_Days(dateToCheck) ) then
returnValue = false
end
return returnValue
end
-- Make sure the variables are correct at startup
if WorkDay(os.date("*t")) then
fibaro:setGlobal("WorkToday","True");
else
fibaro:setGlobal("WorkToday","False");
end
if WorkDay(os.date("*t", os.time()+24*60*60)) then
fibaro:setGlobal("WorkTomorrow","True");
else
fibaro:setGlobal("WorkTomorrow","False");
end
while true do
local currentDate = os.date("*t");
if (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "00:01") then
-- Only update variables one time each day, 00:01
if WorkDay(os.date("*t")) then
fibaro:setGlobal("WorkToday","True");
else
fibaro:setGlobal("WorkToday","False");
end
if WorkDay(os.date("*t", os.time()+24*60*60)) then
fibaro:setGlobal("WorkTomorrow","True");
else
fibaro:setGlobal("WorkTomorrow","False");
end
end
-- Turn off lamps 22:05 day before workday, and 00:30 day before holiday (test is WorkToday since we change day)
if (
( tonumber(fibaro:getGlobalValue("WorkTomorrow")) == tonumber("True") )
and
( string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "22:05")
)
then
fibaro:call(48, "turnOff");
fibaro:sleep(math.random(6000,9000));
fibaro:call(7, "turnOff");
fibaro:sleep(math.random(8000,12000));
fibaro:call(8, "turnOff");
fibaro:sleep(math.random(5000,12000));
fibaro:call(10, "turnOff");
fibaro:sleep(math.random(2000,5000));
fibaro:call(9, "turnOff");
fibaro:sleep(math.random(8000,12000));
fibaro:call(5, "turnOff");
fibaro:sleep(math.random(6000,9000));
fibaro:call(4, "turnOff");
fibaro:sleep(math.random(5000,8000));
fibaro:call(6, "turnOff");
fibaro:sleep(math.random(10000,30000));
fibaro:call(11, "turnOff");
end
if (
( tonumber(fibaro:getGlobalValue("WorkToday")) == tonumber("False") )
and
( string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "00:30")
)
then
fibaro:call(48, "turnOff");
fibaro:sleep(math.random(6000,9000));
fibaro:call(7, "turnOff");
fibaro:sleep(math.random(8000,12000));
fibaro:call(8, "turnOff");
fibaro:sleep(math.random(5000,12000));
fibaro:call(10, "turnOff");
fibaro:sleep(math.random(2000,5000));
fibaro:call(9, "turnOff");
fibaro:sleep(math.random(8000,12000));
fibaro:call(5, "turnOff");
fibaro:sleep(math.random(6000,9000));
fibaro:call(4, "turnOff");
fibaro:sleep(math.random(5000,8000));
fibaro:call(6, "turnOff");
fibaro:sleep(math.random(10000,30000));
fibaro:call(11, "turnOff");
end
fibaro:sleep(60*1000);
end
Code: Select all
--[[
%% autostart
%% properties
%% globals
--]]
function Vacation_Days(dateForCheck)
-- Ange vilka datum som skall anses som lediga datum
local LedigaDatum = { "2014-05-02" , "2014-05-30" }
local datum
for z,datum in pairs(LedigaDatum)
do
TestDatum = os.date("*t", os.time({year = tonumber(string.sub(datum,1,4)), month = tonumber(string.sub(datum,6,7)), day = tonumber(string.sub(datum,9))}))
if ( TestDatum.year == dateForCheck.year and TestDatum.month == dateForCheck.month and TestDatum.day == dateForCheck.day ) then
return true
end
end
return false
end
function Holidays_CalculateEaster(year)
golden = (year % 19) + 1
c = math.floor(year/400) + math.floor(8*(math.floor(year/100)+11)/25) - math.floor(year/100)
s = (11 * golden + c) % 30
if (s < 0) then
s = s + 30
end
pfm = os.time{year=year, month=4, day=19} - s * 24 * 60 * 60
if (pfm == os.time{year=year, month=4, day=19}) then
pfm = pfm - 24 * 60 * 60
elseif (pfm == os.time{year=year, month=4, day=18} and golden > 11) then
pfm = pfm - 24 * 60 * 60
end
sunday = pfm + (7 - tonumber(os.date("%w", pfm))) * 24 * 60 * 60
friday = sunday - 2 * 24 * 60 * 60
return {year, tonumber(os.date("%m", friday)), tonumber(os.date("%d", friday))}
end
function WorkDay(dateToCheck)
local easterDay
local returnValue
returnValue = true
-- Indatum är en lördag eller Söndag
if ( dateToCheck.wday == 1 or dateToCheck.wday == 7 ) then
returnValue = false
-- Indatum är nationaldag
elseif ( dateToCheck.month == 6 and dateToCheck.day == 6 ) then
returnValue = false
-- Indatum är Nyårsdag eller trettondag
elseif ( dateToCheck.month == 1 and (dateToCheck.day == 1 or dateToCheck.day == 6 ) ) then
returnValue = false
-- Indatum är 1:a maj
elseif ( dateToCheck.month == 5 and dateToCheck.day == 1 ) then
returnValue = false
-- Indatum är Julafton,Juldag, Annandag eller Nyårsafton
elseif ( dateToCheck.month == 12 and (dateToCheck.day == 24 or dateToCheck.day == 25 or dateToCheck.day == 26 or dateToCheck.day == 31) ) then
returnValue = false
end
-- Långfredag
easterDay = Holidays_CalculateEaster(dateToCheck.year)
if ( easterDay[1] == dateToCheck.year and easterDay[2] == dateToCheck.month and easterDay[3] == dateToCheck.day ) then
returnValue = false
end
-- AnnandagPåsk
easterDay2 = os.date("*t", os.time({year = easterDay[1], month = easterDay[2], day = easterDay[3]})+3*24*60*60)
if ( easterDay2.year == dateToCheck.year and easterDay2.month == dateToCheck.month and easterDay2.day == dateToCheck.day ) then
returnValue = false
end
-- Kristihimmelfärdsdag? +41 dagar från Långfredag?
datum3 = os.date("*t", os.time({year = easterDay[1], month = easterDay[2], day = easterDay[3]})+41*24*60*60)
if ( datum3.year == dateToCheck.year and datum3.month == dateToCheck.month and datum3.day == dateToCheck.day ) then
returnValue = false
end
-- hitta midsommardagen för att kunna kontrollera midsommarafton
-- midsommardagen = den lördag som infaller under tiden den 20-26 juni -> midsommarafton bör vara den fredag som inträffar under tiden 19-25 juni
if ( dateToCheck.month == 6 and (dateToCheck.day >= 19 and dateToCheck.day <= 25) and dateToCheck.wday == 6 ) then
returnValue = false
end
if ( Vacation_Days(dateToCheck) ) then
returnValue = false
end
return returnValue
end
-- Main Start
-- Make sure the variables are correct at startup
if WorkDay(os.date("*t")) then
fibaro:setGlobal("WorkToday","True");
else
fibaro:setGlobal("WorkToday","False");
end
if WorkDay(os.date("*t", os.time()+24*60*60)) then
fibaro:setGlobal("WorkTomorrow","True");
else
fibaro:setGlobal("WorkTomorrow","False");
end
-- Main Loop
while true do
local currentDate = os.date("*t");
-- Only update variables one time each day, 00:01
if (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "00:01") then
if WorkDay(os.date("*t")) then
fibaro:setGlobal("WorkToday","True");
else
fibaro:setGlobal("WorkToday","False");
end
if WorkDay(os.date("*t", os.time()+24*60*60)) then
fibaro:setGlobal("WorkTomorrow","True");
else
fibaro:setGlobal("WorkTomorrow","False");
end
end
-- Turn off lamps 22:05 day before workday,
-- and 00:30 day before holiday (test is WorkToday since we are after midnight)
if (
(fibaro:getGlobalValue("WorkTomorrow") == "True")
and
( string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "22:30")
)
then
fibaro:call(48, "turnOff");
fibaro:sleep(math.random(6000,9000));
fibaro:call(7, "turnOff");
fibaro:sleep(math.random(8000,12000));
fibaro:call(8, "turnOff");
fibaro:sleep(math.random(5000,12000));
fibaro:call(10, "turnOff");
fibaro:sleep(math.random(2000,5000));
fibaro:call(9, "turnOff");
fibaro:sleep(math.random(8000,12000));
fibaro:call(5, "turnOff");
fibaro:sleep(math.random(6000,9000));
fibaro:call(4, "turnOff");
fibaro:sleep(math.random(5000,8000));
fibaro:call(6, "turnOff");
fibaro:sleep(math.random(10000,30000));
fibaro:call(11, "turnOff");
end
if (
(fibaro:getGlobalValue("WorkToday") == "False")
and
( string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "00:30")
)
then
fibaro:call(48, "turnOff");
fibaro:sleep(math.random(6000,9000));
fibaro:call(7, "turnOff");
fibaro:sleep(math.random(8000,12000));
fibaro:call(8, "turnOff");
fibaro:sleep(math.random(5000,12000));
fibaro:call(10, "turnOff");
fibaro:sleep(math.random(2000,5000));
fibaro:call(9, "turnOff");
fibaro:sleep(math.random(8000,12000));
fibaro:call(5, "turnOff");
fibaro:sleep(math.random(6000,9000));
fibaro:call(4, "turnOff");
fibaro:sleep(math.random(5000,8000));
fibaro:call(6, "turnOff");
fibaro:sleep(math.random(10000,30000));
fibaro:call(11, "turnOff");
end
fibaro:sleep(60*1000);
end
Bamsefar wrote:Right - mera slarvfel från min sida - sorry for that - skall bättre mig
Johan71: Radera din första scen (kalender) och BYT den andra (kväll) till nedanstående kod:sonnyboy: Du får ta koden ovan och byta ut enheterna på slutet.Code: Select all
--[[ %% autostart %% properties %% globals --]] function Vacation_Days(dateForCheck) -- Ange vilka datum som skall anses som lediga datum local LedigaDatum = { "2014-05-02" , "2014-05-30" } local datum for z,datum in pairs(LedigaDatum) do TestDatum = os.date("*t", os.time({year = tonumber(string.sub(datum,1,4)), month = tonumber(string.sub(datum,6,7)), day = tonumber(string.sub(datum,9))})) if ( TestDatum.year == dateForCheck.year and TestDatum.month == dateForCheck.month and TestDatum.day == dateForCheck.day ) then return true end end return false end function Holidays_CalculateEaster(year) golden = (year % 19) + 1 c = math.floor(year/400) + math.floor(8*(math.floor(year/100)+11)/25) - math.floor(year/100) s = (11 * golden + c) % 30 if (s < 0) then s = s + 30 end pfm = os.time{year=year, month=4, day=19} - s * 24 * 60 * 60 if (pfm == os.time{year=year, month=4, day=19}) then pfm = pfm - 24 * 60 * 60 elseif (pfm == os.time{year=year, month=4, day=18} and golden > 11) then pfm = pfm - 24 * 60 * 60 end sunday = pfm + (7 - tonumber(os.date("%w", pfm))) * 24 * 60 * 60 friday = sunday - 2 * 24 * 60 * 60 return {year, tonumber(os.date("%m", friday)), tonumber(os.date("%d", friday))} end function WorkDay(dateToCheck) local easterDay local returnValue returnValue = true -- Indatum är en lördag eller Söndag if ( dateToCheck.wday == 1 or dateToCheck.wday == 7 ) then returnValue = false -- Indatum är nationaldag elseif ( dateToCheck.month == 6 and dateToCheck.day == 6 ) then returnValue = false -- Indatum är Nyårsdag eller trettondag elseif ( dateToCheck.month == 1 and (dateToCheck.day == 1 or dateToCheck.day == 6 ) ) then returnValue = false -- Indatum är 1:a maj elseif ( dateToCheck.month == 5 and dateToCheck.day == 1 ) then returnValue = false -- Indatum är Julafton,Juldag, Annandag eller Nyårsafton elseif ( dateToCheck.month == 12 and (dateToCheck.day == 24 or dateToCheck.day == 25 or dateToCheck.day == 26 or dateToCheck.day == 31) ) then returnValue = false end -- Långfredag easterDay = Holidays_CalculateEaster(dateToCheck.year) if ( easterDay[1] == dateToCheck.year and easterDay[2] == dateToCheck.month and easterDay[3] == dateToCheck.day ) then returnValue = false end -- AnnandagPåsk easterDay2 = os.date("*t", os.time({year = easterDay[1], month = easterDay[2], day = easterDay[3]})+3*24*60*60) if ( easterDay2.year == dateToCheck.year and easterDay2.month == dateToCheck.month and easterDay2.day == dateToCheck.day ) then returnValue = false end -- Kristihimmelfärdsdag? +41 dagar från Långfredag? datum3 = os.date("*t", os.time({year = easterDay[1], month = easterDay[2], day = easterDay[3]})+41*24*60*60) if ( datum3.year == dateToCheck.year and datum3.month == dateToCheck.month and datum3.day == dateToCheck.day ) then returnValue = false end -- hitta midsommardagen för att kunna kontrollera midsommarafton -- midsommardagen = den lördag som infaller under tiden den 20-26 juni -> midsommarafton bör vara den fredag som inträffar under tiden 19-25 juni if ( dateToCheck.month == 6 and (dateToCheck.day >= 19 and dateToCheck.day <= 25) and dateToCheck.wday == 6 ) then returnValue = false end if ( Vacation_Days(dateToCheck) ) then returnValue = false end return returnValue end -- Main Start -- Make sure the variables are correct at startup if WorkDay(os.date("*t")) then fibaro:setGlobal("WorkToday","True"); else fibaro:setGlobal("WorkToday","False"); end if WorkDay(os.date("*t", os.time()+24*60*60)) then fibaro:setGlobal("WorkTomorrow","True"); else fibaro:setGlobal("WorkTomorrow","False"); end -- Main Loop while true do local currentDate = os.date("*t"); -- Only update variables one time each day, 00:01 if (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "00:01") then if WorkDay(os.date("*t")) then fibaro:setGlobal("WorkToday","True"); else fibaro:setGlobal("WorkToday","False"); end if WorkDay(os.date("*t", os.time()+24*60*60)) then fibaro:setGlobal("WorkTomorrow","True"); else fibaro:setGlobal("WorkTomorrow","False"); end end -- Turn off lamps 22:05 day before workday, -- and 00:30 day before holiday (test is WorkToday since we are after midnight) if ( (fibaro:getGlobalValue("WorkTomorrow") == "True") and ( string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "22:30") ) then fibaro:call(48, "turnOff"); fibaro:sleep(math.random(6000,9000)); fibaro:call(7, "turnOff"); fibaro:sleep(math.random(8000,12000)); fibaro:call(8, "turnOff"); fibaro:sleep(math.random(5000,12000)); fibaro:call(10, "turnOff"); fibaro:sleep(math.random(2000,5000)); fibaro:call(9, "turnOff"); fibaro:sleep(math.random(8000,12000)); fibaro:call(5, "turnOff"); fibaro:sleep(math.random(6000,9000)); fibaro:call(4, "turnOff"); fibaro:sleep(math.random(5000,8000)); fibaro:call(6, "turnOff"); fibaro:sleep(math.random(10000,30000)); fibaro:call(11, "turnOff"); end if ( (fibaro:getGlobalValue("WorkToday") == "False") and ( string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "00:30") ) then fibaro:call(48, "turnOff"); fibaro:sleep(math.random(6000,9000)); fibaro:call(7, "turnOff"); fibaro:sleep(math.random(8000,12000)); fibaro:call(8, "turnOff"); fibaro:sleep(math.random(5000,12000)); fibaro:call(10, "turnOff"); fibaro:sleep(math.random(2000,5000)); fibaro:call(9, "turnOff"); fibaro:sleep(math.random(8000,12000)); fibaro:call(5, "turnOff"); fibaro:sleep(math.random(6000,9000)); fibaro:call(4, "turnOff"); fibaro:sleep(math.random(5000,8000)); fibaro:call(6, "turnOff"); fibaro:sleep(math.random(10000,30000)); fibaro:call(11, "turnOff"); end fibaro:sleep(60*1000); end
Fråga: Vill ni verkligen ha det exakt 22:05 resp 00:30 - eller önskar ni slumpvis släckning oxå? Alltså säg mellan 22:00 - 22:15 resp 00:25 - 00:40?
Det skulle ju vara riktigt fränt med slumpvis släckningJohan71 wrote:Fråga: Vill ni verkligen ha det exakt 22:05 resp 00:30 - eller önskar ni slumpvis släckning oxå? Alltså säg mellan 22:00 - 22:15 resp 00:25 - 00:40?
Nu först ser jag två saker:sonnyboy wrote:Hm workday false, då ska det slockna klockan 23, 30. Nu 23.51 stängde jag ner manuellt. Är det pga röda dagen i morgon som det blir nå knas? Funkar hur bra som helst på helgen.
Skickat från min SM-G900F via Tapatalk
Något med forumklockan, jag bor I Västeras.Bamsefar wrote:1. Du skriver 23.51 men inlägget är postat 22.53 - vart lever du eller är det forumets klocka som går galet?
Skulle vara workday tomorrow false, och då ska det släckas 23:20 annars 22:22Bamsefar wrote:2. Den 30e april är inte false, det var den inte hos mig för då var jag hemma - MEN hemma hos mig så skall lamporna slockna senare DAG FÖRE LEDIG DAG. Alltså workdaytomorrow är false. Således vad menar du - eller kan du posta koden så kan jag kolla om det finns något som påverkar?
Tankevurpa från mig, tänkte den 30 maj var röd dag men så är det ju inte, jag är bara ledig.Bamsefar wrote:Och sedan då:
3. Varför först den 30e Maj
Code: Select all
-- Ange vilka datum som skall anses som lediga datum
local LedigaDatum = { "2014-05-02" , "2014-05-30" }
(fibaro:getGlobalValue("WorkTomorrow") == "True")
and
( string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "22:22")
)
then
fibaro:call(38, "turnOff");--Köksfönstren
fibaro:sleep(math.random(8000,12000));
fibaro:call(4, "turnOff");--Bakom Soffan
fibaro:sleep(math.random(5000,8000));
fibaro:call(33, "turnOff");--Vitrinskåpet
fibaro:sleep(math.random(8000,12000));
fibaro:call(45, "turnOff");--Bakom Tvn
fibaro:sleep(math.random(8000,12000));
fibaro:call(36, "turnOff");--Fönsterlampa Alcia
fibaro:sleep(math.random(8000,12000));
fibaro:call(34, "turnOff");--Lampa Byrån
fibaro:sleep(math.random(8000,12000));
end
(fibaro:getGlobalValue("WorkToday") == "False")
and
( string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "23:20")
)
then
fibaro:call(38, "turnOff");--Köksfönstren
fibaro:sleep(math.random(8000,12000));
fibaro:call(4, "turnOff");--Bakom Soffan
fibaro:sleep(math.random(5000,8000));
fibaro:call(33, "turnOff");--Vitrinskåpet
fibaro:sleep(math.random(8000,12000));
fibaro:call(45, "turnOff");--Bakom Tvn
fibaro:sleep(math.random(8000,12000));
fibaro:call(36, "turnOff");--Fönsterlampa Alcia
fibaro:sleep(math.random(8000,12000));
fibaro:call(34, "turnOff");--Lampa Byrån
fibaro:sleep(math.random(8000,12000));
end