motion sensor wyłacza światło

  • 0 Odpowiedzi
  • 1507 Wyświetleń

0 użytkowników i 1 Gość przegląda ten wątek.

motion sensor wyłacza światło
« dnia: Styczeń 21, 2018, 08:37:31 pm »
Witam wszystkich to jest mój pierwszy post itd...
mam prostą scenę opartą na motion sensor który ma wyłączać światło po 120s.
Scena przekracza liczbę instalacji
trzeba by coś dopisać w kodzie LUA żeby scena się przedłużała jeżali w czasie tych 120s nastąpi ruch.

Proszę o pomoc bo nic prostego nie znalazłem

--[[
%% properties
231 value
%% weather
%% events
%% globals
--]]

local startSource = fibaro:getSourceTrigger();
if(startSource["type"] == "other") then
   fibaro:call(113, "turnOff");
   fibaro:call(201, "turnOff");
else
if (( tonumber(fibaro:getValue(231, "value")) == 0 )) then
setTimeout(function()
local delayedCheck0 = false;
local tempDeviceState0, deviceLastModification0 = fibaro:get(231, "value");
if (( tonumber(fibaro:getValue(231, "value")) == 0 ) and (os.time() - deviceLastModification0) >= 120) then
   delayedCheck0 = true;
end

local startSource = fibaro:getSourceTrigger();
if (
 ( delayedCheck0 == true )
or
startSource["type"] == "other"
)
then
   fibaro:call(113, "turnOff");
   fibaro:call(201, "turnOff");
end
end, 120000)
end
end