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
Rakurs 0
Hello!
I have a fibaro motion sensor and LED strip to dimm it.
I need to implement next scenario:
If I in home LED on for 40% and when motion will be detect it dimm up to 100%, after 15 minutes it will dimm to 40% back.
When I go out home (global "InHome" - Yes or No) LED turn off.
So, the code:
--[[
%% properties
234 value
214 value
%% globals
--]]
-- Configuration of variables (id of motion sensor must be entered under %% properties above---------------------------------------------------------------------------------------------------------------------
local scene = 30 -- ID of this scene
local motion = 234 -- ID motion sensor
--local motion2 = 170 -- ID 2nd motion sensor
local switch = 214 -- ID of lamp
-- local switch2 = 152 -- ID of 2nd lamp
local InHome = fibaro:getGlobalValue("InHome")
local starttimer = 120 -- time in s, the lights stay on (+ time set in motion sensor - par. 6)
-----------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------
---------------------Script-----------------
fibaro:debug("start")
if (fibaro:countScenes()>1) then
fibaro:debug("stop scene");
fibaro:abort();
end
-- SWITCH LIGHT ON/OFF (if not day)
if (tonumber(fibaro:getValue(motion, "value")) > 0 ) and InHome == "Yes" then
--Turn Light(s) on
fibaro:call(switch, "setValue", "100");
--fibaro:call(switch2, "turnOn");
-- timer start und configure
timer = os.time();
while os.time() - timer < starttimer do
fibaro:sleep(1000);
-- set timer to zero if another motion is detected during delay (set in starttimer)
if (tonumber(fibaro:getValue(motion, "value"))) > 0 then
timer = os.time();
end
end
if InHome == "Yes" then
fibaro:call(switch, "setValue", "40");
else
fibaro:call(switch, "setValue", "0");
end
end
fibaro:debug("end");
fibaro:killScenes(scene);
It work good, but it have one problem: if i InHome=Yes and there is no motion it first dimm to 40% and then after some time (different every time) it turned off.
May be someone can find a problem in scene?
Thank you!
0 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.