W razie czego przy pomocy kolegi z innego forum udało się i działa to co wyżej chciałem
Problem pojawiał się ponieważ w jednej scenie nie dało się właczyć to czego chciałem dlatego trzeba po przez tą scenę uciekać do innej - może sie komuś to przyda.
Scena wywoływana jest tylko raz dziennie między 7.00 - 9.00 pod warunkiem ze motion wykryje ruch
--[[
%% properties
602 value
%% weather
%% events
%% globals
--]]
local motionId = 602;
local morningTime = "07:00-09:00";
local startSource = fibaro:getSourceTrigger();
function between(str)
-- get current time
local t = os.date("*t", os.time())
local h1,m1,h2,m2 = str:match("(%d+)
%d+)-(%d+)
%d+)")
m1, m2, t = h1*60+m1, h2*60+m2, t.hour*60+t.min
if (m1 <= m2) then
return m1 <= t and t <= m2 -- 01:00-02:00
else
return m1 <= t or t <= m2 -- 23:00-21:00
end
end
function isToday()
local when = tonumber(fibaro:getGlobalValue('I_got_up', 0));
local daysfrom = os.difftime(os.time(), when) / (24 * 60 * 60);
local wholedays = math.floor(daysfrom);
fibaro:debug(wholedays); -- 0 today > 0 next days
if wholedays == 0 then
return false;
else
fibaro:setGlobal("I_got_up", os.time())
return true;
end
end
if ( ( tonumber(fibaro:getValue(motionId, "value")) > 0 ) or
( startSource["type"] == "other" ) ) then
fibaro:debug("Motion detected!");
-- is morning?
if between(morningTime) then
fibaro:debug("Morning hours");
if isToday() then
fibaro:debug("dowolne przejście lub właczenie inej sceny ");
else
fibaro:debug("Do jutra");
end
end
end