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

Brand new to HC2 & LUA - Can't get motion LUA to work for lights


themoonmonkey

Question

Hi all,

 

I've done a quick search but can only find incredibly complex scripts to work with the motion sensor on here - I'm just trying to learn the basics first! I have a Fibaro Dimmer2 controlling wall lights and a Fibaro Motion Sensor. I want to turn the lights on when it detects movement and then turn them off after it has checked for 5 minutes of no activity. 

 

Using this page by FibaroUK: 

Please login or register to see this link.

 

and this LUA script: 

Please login or register to see this code.

It works if I run it manually, but then it won't work automatically. Also, is this the only scene I need to create? It says about using the Blocks Scene for On / Off but then mentions:

 

We can write the same scene again in Lua and add the extra functionality to pause for 60 seconds if there has been no movement.  We check for movement again after the 60 seconds – just in case someone has come back into the room again.

 

 

 

So I'm assuming that I don't need the block scenes? Sorry, I appreciate this is probably really stupid questions - but gotta start somewhere!

 

Thanks,

 

Josh

 

 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

The LUA scene is a more advanced version of the block scene,adding the extra feature to pause for 60 seconds (30 in your case) it there has been no movement.

So, you don't need to create a block scene if you already use the LUA one.

However, you should verify that the "active scene" checkmark is enabled. Otherwise the scene will not be responsive to external triggers.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Thanks Brick, so I have deleted the block scenes and just have this LUA scene. It's marked as active and for testing I've set it to 10 seconds. However it still doesn't trigger when I breach the PIR (ID 56). 

     

    I've attached screenshots of the general and advanced tabs. These motionID and wallLightID are the correct ones (I double checked). 

     

    Please login or register to see this link.

    Please login or register to see this link.

    Link to comment
    Share on other sites

    • 0

    You forgot to add the headers:

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0

    Is it really your code in the scene?

    It should look like that

    Please login or register to see this code.

    Delete your code and copy this one as is.

    Another issue, is that you wait 5 minutes after sensor goes off. Please remember that your scene could be triggered many times during this period. You're gonna have many instances which will turn off your light unexpectedly. 

    Link to comment
    Share on other sites

    • 0

    You do not need the delay in the script to check for missing motion, you can use parameter 6 of the motion detector to do the job for you.

    Have parameter 6 set to 30 seconds and it will wait for 30 seconds from the last detection, before it reports to the controller that there has been no motion.

    Then you can simply shut off the lights, when the controller receives the "no motion" report from the detector.

    Make a script, or block scene, that turns on light when motion is detected and another that turns off the light, when the PIR reports no motion and adjust the delay on the motion sensor.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thanks all for the help. Went with parameter 6 and the block scene which has worked perfectly.

     

    And cag014, nope - not my code. I said I got it from FibaroUK website! 

    Please login or register to see this link.

    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.

    ×
    ×
    • Create New...