Jump to content

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


  • 0

Movement and Door sensor not working as a team,,:(


Jasperwaale
 Share

Question

 

Hi 

 

Im reading your block, and I like your LUA scripts for Z-wave, Thanks it helps to have something like that to look at, 

 

Im having a problem with My WC that also is a storage for some cleaning things, Using the Fibaro Motion to pickup

moments and turn on lights works well,  It will time out after 2 min, However I also like the lights to be on with no time out when the door is closed.

 

So I install the Windows/Door sensor from fibaro so it also turn on lights when door is closed and off when then open, however 

the Timer on the movements kicks in and turn off the lights after 2 min regardless if door open or closed 

 

Any Tips your able to share ? 

 

Thanks Im not a programmer, but Im able to read logic code if needed  

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

set a variable when the door closes or opens. Then when make the light switch off or time out only when the vaiable changes back, i.e. when the door opens.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Trying this out, Thanks to Jonas Lundblad m punkt nu Sverige AB 

    Please login or register to see this link.

     - 

    Please login or register to see this link.

     - 

    Please login or register to see this link.

     - 

    Please login or register to see this link.

      Facebook: 

    Please login or register to see this link.

     Twitter: 

    Please login or register to see this link.

     

    Blog is good and Jonas been helpfull

     

    --[[
    %% properties
    372 value
    %% globals
    --]]
    local sceneId = 16 --ID of this scene, used to detect number of instances run
    local timerEndTime = 180 --Seconds to keep the lamp turned on after PIR detects movement
    local timer = "timer" --Name of global variabel to control the timer
    local timerValue = fibaro:getGlobalValue(timer) --Current value of global variabel for timer
    local doorsensor = 372
    if fibaro:getValue(doorsensor, "value") == 1 then --door closed, turn on
       fibaro:call(lights, "turnOn")
       fibaro:abort() -- exit scene
    end
    else if fibaro:getSourceTrigger() == doorsensor and fibaro:getValue(doorsensor, "value") == 0 then -- door opened, turn off if scene called by door sensor
       fibaro:call(lights, "turnOff")
       fibaro:setGlobal(timer, 0) -- stop timer
       fibaro:abort() --exit scene
    end

    if fibaro:countScenes(sceneId) > 1 then  --if scene is already running , reset the timer to 3 minutes 
        fibaro:setGlobal(timer, timerEndTime) --set global variabel for timer to 2 minutes 
        fibaro:abort()  -- abort scene
    end

    fibaro:call(lights, "turnOn") --Turn lights on 
        fibaro:setGlobal(timer, timerEndTime) --Set global variabel for timer 
        while (fibaro:getGlobalValue(timer) ~= "0") do --loop until timer is 0
          timerValue = tonumber(fibaro:getGlobalValue(timer)) --Get current value of global variabel timer 
          fibaro:setGlobal(timer, timerValue-1) --Decrease global variabel for timer with 1 second 
          fibaro:debug("Loop - timer = " .. fibaro:getGlobalValue(timer)) --debug
          fibaro:sleep(1000) --Wait 1 second
        end 
        fibaro:call(lights, "turnOff") --Turn lights off 

    end
    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

     Share

    ×
    ×
    • Create New...