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

Fibaro motion sensor triggers in lua


Question

Posted

Hi

 

I am new to Fibaro and lua since a week or so. Just tried to create some lua scripts and a few global variables. But due to lack of documentation I have a few question of the behavior of the motion sensor.

 

I have a Fibaro mutlisensor and trigger on ""<device id> value" in one scene. My lua script do not however work as expected. The script shall light up a dimmer 2 to a certain value if it sees motion and it is below nn lux. And if someone touch the wall switch (set to off or change the light level)  the scene should exit and auto-trigger next time the light is off if lux and motion matches. If motion is seen when the light is on and it was light up by the scene and not manually the timer should be reset to extend the on time. If motion is seen if the light was manually switched on, the motion sensor should not trigger anything.  

 

The scene trigger on movement. But I also use "lastBreached" in the lua script.

 

Now...

 

Question 1

I have the motion sensor "Motion detection - alarm cancel delay" to 30s. It seems lastBreach is not updated if you have movement in front of the sensor within this time frame. Therefor, if you have constant movement I will not have a timer reset as the lastBreached wont be updated. If I leave the room and get back a minute later the lastBreached is updated and my timer is reset and keeps the light on. How does this work? Can any kind person describe the trigger, trigger reset, lastBreached etc on the motion sensor as it is not in any manual or spec.

 

Question 2

It seems the motion sensor value triggers the scene both when it sees motion and also when it resets after the "Motion detection - alarm cancel delay". Probably to it is a change of the "value". This causes unnecessary coding to go around. It it possible to trigger a scene just on when the motion sensor sees motion and not when it resets the value back? How?

 

 

Thanks in advance

/Peo

 

2 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Posted

    I think I get it now and answer it myself.

     

    As I do not want the scene to trigger on the "motion detection - cancel delay" (i.e 1 --> 0) I exit with this..

    --snip--

    if  ((tonumber(fibaro:getValue(motionSensorID, "value"))) == 0) then
        if DEBUG == 1 then fibaro:debug('Motion sensor reset trigger. Not used! Abort..') end
          fibaro:abort()
    end 

    --snip--

     

    I also had unwanted scene triggers caused by no longer used global variables that are used in the lua script but no longer set as a triggers in the lua header. This is a bug according to others. A HC2 reboot and this went away. That confirmed the bug to me... Just hope it it logged to Fibaro as other people have seen this before me...

     

    And lastly... it seems motion sensor "lastBreached" on the motion sensor can only get set to a new EPOC time number if the  "value" has returned to 0 so the whole cancel delay has gone. If I want it sooner it seems I have to decrease the "motion detection - cancel delay" time, that I guess will eat more batteries. But it seems this has to be decreased in my case. Otherwise a person can walk around within this 30s intervall when the light is on, then leave the area before the  "motion detection - cancel delay" has ended, and the timer will never be reset so the light will be shut off.

     

    Is this conclusion correct?

     

     

    /Peo

    • 0
    Posted

    Besides your own solution, did you check also:

    It has a lot of function, just chuck it into a room and it can do a whole lot of things. Since i saw that you only had 7 posts, don't know how far you went into this matrix called forum ;-) lots of gems.

     

    That said, motion sensors that say "breached" might just mean "motion detected" so words can be read differently in some explanations.

     

    For what i know from motion sensors is they tend to "breach" then have a period have a settings that says "don't re-breach within xx seconds" a setting for "arm after xx seconds" and a reset the timer for the arm when it is re-breached inside the breach window. Just by reading the config parameters of the device usually helps a lot (assuming its a fibaro motion sensor) it comes with so many options. Hope this helps 'some' 

    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.

    ×
    ×
    • Create New...