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

Lights ON until no more activity


Barry Kripke
 Share

Question

(I'm a n00b. Using a Home Center 2)

 

I have a space where I want any one of three (motion) sensors to be able to switch lights on, and when not more activity has been sense for some time, switch them off. 

I'd like to extend it such that the lights only come on between sunset and sunrise. 

 

I have created 4x scenes, 3x Turn On, 1x Turn Off.

 

The logic I am using is:

I created a Global Variable (called LastOnTime) to track the last activation/on time. 

All of the motion sensors trigger a scene that turn the lights on; and set the LastOnTime to os.time() - I have three copies of that scene.

I created one more scene that is triggered off a timer; then if [os.time() - LastOnTime] > 600 turn the lights off. 

 

The scripts are below. 

 

Questions I have are:

  1. is this a good way of doing it? is there a better way?
  2. the timer is not working (the scenes are not triggered). I found this 'hack' somewhere in this forum.
  3. how do I put something here to check os.time() > [sunset] ?

 

----------

 

The On scenes look like: 

Please login or register to see this code.

 

 

The Off script looks like:

Please login or register to see this code.

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

For your 3rd point, a tip: You can create a block scene that turns on a light at sunset. Then convert the block scene to LUA (using the button in the block editor). Voila, you have the code you can add to your script.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • On 1/20/2022 at 2:51 AM, Tim__ said:

    For your 3rd point, a tip: You can create a block scene that turns on a light at sunset. Then convert the block scene to LUA (using the button in the block editor). Voila, you have the code you can add to your script.

    I created a variable; at sunrise it is set to 1, sunset it is set to 0.

    The the scenes check the value of that variable. 

    Link to comment
    Share on other sites

    • 0

    Instead of creating so many scenes for such a simple action, I suggest to download and using  

    Please login or register to see this link.

     

    Try it... no Lua code required....

    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...