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

Lua Scene optimisation. [Help]


Question

Posted (edited)

Hello, I have some scenes to control my lights:

 

Scene 1- If motion is detected, then turn ON light and change Variable = AUTO.

Scene 2- If Variable == AUTO, then change Variable = RUNNING and after 60s ( turn OFF light and change Variable = Manual ).

Scene 3- This is for stoping the Scene 2, If I press a switch, then turn light ON ( because it turned OFF when I press the switch ) and Stop Scene 2 and change Variable = Manual.

Scene 4- If motion is detected and Variable == RUNNING, restart Scene 2 ( to restart the 60s timer if motion is detected ).

 

 

This is the code of the scenes:

 

Scene 1:

Please login or register to see this code.

Scene 2:

Please login or register to see this code.

Scene 3:

 

Scene 4:

Please login or register to see this code.

My question is, as I'm really new to Lua, and Fibaro HC2 I want to know if somehow I can optimise this to use less scenes, I think that Scene 2 ( 60s timer ) have to be separated, so I can restart the 60s timer but I can be wrong.

 

If anybody is in the mood and want to help I'll be appreciated.

Please login or register to see this image.

/emoticons/default_wink.png" alt=";)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

Thanks.

 

Edited to say that I have to remove the Scene 3, I don't now why but that was messing up with all the rest, and with the Scene 4 to restart the timer I can remove the Scene 3.

Please login or register to see this image.

/emoticons/default_wink.png" alt=";)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

Edited by Morcegolas

2 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Posted

    Alright, we all have to start programming some time sooner or later. So this is me trying to start to learn

    Please login or register to see this image.

    /emoticons/default_wink.png" alt=";)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

     

    I tried to create the code for the situation explained earlier, putting every scene in one function, but I have 99% sure that this code won't work, because I'm new to this and have almost zero knowledge of programming. But at least I'm trying, so I call the first function but none of the others, can anybody help me with this? You may also add comments to the code so it's easier to understand and learn

    Please login or register to see this image.

    /emoticons/default_wink.png" alt=";)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    Please login or register to see this code.

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