Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- %% properties
- 69 value
- %% globals
- --]]
- local motionID = 69
- local lightID = 30
- local sonosCommander = 73
- timeWithOutMotion = 120
- if (tonumber(fibaro:countScenes())>1) then
- fibaro:debug('Kill second scene!')
- fibaro:abort()
- end
- 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) then
- fibaro:call(sonosCommander, 'pressButton', '1')
- 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(sonosCommander, 'pressButton', '4')
- fibaro:call(lightID, 'turnOff');
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement