Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- %% properties
- 43 value
- 175 value
- %% globals
- --]]
- motionID = 93; -- MotionSensor1
- motionID2 = 175; -- MotionSensor2
- lightID = 157; -- LightID
- timeWithOutMotion = 120; -- Zeit in Sekunden; bitte anpassen
- if (tonumber(fibaro:countScenes())>1) then
- fibaro:debug('Kill second scene!');
- fibaro:abort();
- end
- local motion2 = fibaro:getValue(motionID2, 'value');
- local armedMotion2, lastArmedMotion2 = fibaro:get(motionID2, 'armed');
- local motion = fibaro:getValue(motionID, 'value');
- local armedMotion, lastArmedMotion = fibaro:get(motionID, 'armed');
- local trigger = fibaro:getSourceTrigger();
- if (tonumber(trigger['deviceID'])==tonumber(motionID)) then
- if (tonumber(motion)==1 and fibaro:getGlobalValue("Sonnenstand") == "Sonnenuntergang") then
- fibaro:call(lightID, "turnOn");
- fibaro:debug('Motion detected. Light on!');
- fibaro:call(motionID, 'setArmed', '1');
- fibaro:call(motionID, 'setArmed', '0');
- -- no motion anymore
- elseif (tonumber(motion)==0 and (os.time()-lastArmedMotion)>=timeWithOutMotion) then
- fibaro:debug('No motion. Light off!')
- fibaro:call(lightID, "turnOff");
- end
- end
- if (tonumber(trigger['deviceID'])==tonumber(motionID2)) then
- if (tonumber(motion2)==1 and fibaro:getGlobalValue("Sonnenstand") == "Sonnenuntergang") then
- fibaro:call(lightID, "turnOn");
- fibaro:call(motionID2, 'setArmed', '1');
- fibaro:call(motionID2, 'setArmed', '0');
- -- no motion anymore
- elseif (tonumber(motion)==0 and (os.time()-lastArmedMotion2)>=timeWithOutMotion) then
- fibaro:debug('No motion2. Light off!')
- fibaro:call(lightID, "turnOff");
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement