Welcome to Smart Home Forum by FIBARO
Search the Community
Showing results for tags 'lamp'.
Hey FIBARO Community, i started to code my own scenes in lua some days ago and finally finished some automated parts. The script is working well but there is a part i don't know how to fix. I will comment inline so please read the whole topic. 1. Define the motion (ID 102) after the properties to tell the script to act if the value of motion changes --[[ %% properties 102 value %% globals --]] 2. Define all ID's i want to use in this script local scene = 109 -- ID of this scene local motion = 102 -- ID motion sensor local deckenlampetreppe = 84 -- ID of the lamp 3. Time in seconds the lamp should be activated local starttimer = 10 -- activate lamp in seconds 4. Write the motion value to a variable and convert it from string to integer to be able to work with it later local motionwert = tonumber(fibaro:getValue(motion, "value")); 5. Check if this scene is already active and stop if its true if (fibaro:countScenes()>1) then fibaro:abort(); end 6. If motion is activated (value is > 0), activate the lamp if (motionwert > 0 ) then fibaro:call(deckenlampetreppe, "turnOn"); 7. Set the current time to the variable timer and as long as the current time minus the 'timer' is smaller then the 'starttimer' that was set on top, let the script sleep. If there is still movement reset the timer to hold the lamp activated. timer = os.time(); while os.time() - timer < starttimer do fibaro:sleep(1000); if (tonumber(fibaro:getValue(motion, "value"))) > 0 then timer = os.time(); end end 8. If the difference in seconds is higher then defined on top, disable the lamp again fibaro:call(deckenlampetreppe, "turnOff"); 9. End the if and kill the scene end fibaro:killScenes(scene); Okay this is the script and its working well but? This is right -> If i activate the lamp on the switch the lamp stays activated and works. This fails -> If i disable the lamp on the switch the motion sensor does not activate the lamp again if i walk into it. It looks like the motion sensor still sleeps and i need to wait like 30 seconds before it is working again. I already tried to change some parameters (2,6) on the motion settings but nothing helps me out here. I want that the motion always works and checks and starts the scene also when i disabled the lamp with the switch some seconds before. I already tried to write another scene that kills the motion scene from above when i turn the switch because i was thinking its still running and can't run twice but it feels for me that the motion needs like 30 - 40 seconds to get back to working. I really hope you can help me out here. Greetings, tiCeR