Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team

Question
donangelo 0
Hi
I'm a very beginner with LUA, I found a nice script that turns on light on movement and turns it of after a while, when no movement is recognized.
The script works well and does exactly what I want, but it does it only once. After the light is turned of, it does not switch on any more, only if i restart the script manually.
Has somebody an idea what I do wrong? thank you
Angelo
-> original script by
Please login or register to see this link.
--[[
%% properties
%% autostart
%% properties
100 value
132 value
%% globals
** Automatic light switch turning on when motion is detected. During a 2 minute
period the scene checks for additional movement. If there is movement, the countdown starts
over for another 2 minutes. All until there has been no movement for the duration of 2 minutes.
--]]
local LightID = 132
local MotionSensorID = 100
if fibaro:getValue(LightID, "value") == "1" then
repeat
local LightStatus = fibaro:getValue(LightID, "value")
fibaro:debug("Licht is aktuell an, warte 2 Minuten")
fibaro:sleep(2*60000)
until fibaro:getValue(LightID, "value") == "0"
else
repeat
fibaro:debug(fibaro:getValue(MotionSensorID, "value"))
local MotionSensorState = fibaro:getValue(MotionSensorID, "value")
fibaro:sleep(1*1000);
until MotionSensorState == "1"
fibaro:call(LightID, "turnOn")
fibaro:debug("Licht wurde eingeschaltet")
i = 24
repeat
local MotionSensorState = fibaro:getValue(MotionSensorID, "value")
fibaro:debug(fibaro:getValue(MotionSensorID, "value"))
if MotionSensorState == "1" then i = 24
fibaro:debug("Countdown reset: "..i)
else i = i - 1
fibaro:debug("Countdown: "..i)
end
fibaro:sleep(5*1000);
until i < 1
fibaro:call(LightID, "turnOff")
fibaro:debug("Keine Bewegung mehr, Licht wurde ausgeschaltet")
end
17 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.