Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- %% properties
- 151 value
- %% globals
- --]]
- local sensors = {151}
- local delay = 120
- local debug = false
- local LuxSensorID = 153
- function actionsMotion()
- fibaro:debug('Führe Aktionen bei Bewegungserkennung aus')
- if (
- ( tonumber(fibaro:getValue(LuxSensorID, "value")) <= 1 )
- and ( fibaro:getGlobalValue("PresentState") == "Home" )
- )
- then
- fibaro:call(247, "turnOn")
- fibaro:call(247, "changeBrightness", 30)
- fibaro:debug('Licht WC eingeschaltet')
- end
- end
- function actionsNoMotion()
- fibaro:debug('Führe Aktionen nach Ende Bewegung aus')
- fibaro:call(247, "turnOff")
- fibaro:debug('Licht WC ausgeschaltet!')
- end
- local instances = tonumber(fibaro:countScenes());
- function getSensorStatus()
- for i,n in ipairs(sensors) do
- if (tonumber(fibaro:getValue(n, "value")) > 0) then
- return 1;
- end
- end
- return 0;
- end
- function getLastBreach()
- local breach = 0;
- for i,n in ipairs(sensors) do
- local nBreach = tonumber(fibaro:getValue(n, "lastBreached"));
- if(nBreach > breach) then
- breach = nBreach;
- end
- end
- return breach;
- end
- function checkMotion()
- lastBreached = getLastBreach();
- time = os.time();
- if (debug) then fibaro:debug("Zuletzt ausgelöst: Vor "..(time-lastBreached).." Sekunden"); end
- if (getSensorStatus() == 1) then
- return true;
- end
- if ((time-lastBreached)>=delay) then
- return false;
- end
- return true;
- end
- local lastBreached = getLastBreach()
- if (fibaro:getSourceTriggerType() == 'property' and getSensorStatus() == 1) then
- if (instances > 1) then fibaro:abort(); end
- fibaro:debug('Bewegung im Raum erkannt - Starte Timer')
- actionsMotion()
- while (checkMotion()) do
- fibaro:sleep(5000);
- end
- if (debug) then fibaro:debug("Keine Bewegung mehr erkannt."); end
- actionsNoMotion()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement