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

Automate time trigger


Question

Posted

hello, I have some lighting and alarm scenes (HC2) that are enabled and disabled each at a specific time every day ..... problem: during the year I need to adjust these times several times due to the spring, summer, autumn and winter, the days are getting dark earlier .... any suggestions, please, so that these time adjustments happen automatically or that I can update in one place (Scene, variable or Virtual Device). thanks!

4 answers to this question

Recommended Posts

  • 0
Posted

Hi Jorge,

 

I achieve this in two ways, depending on the complexity of the scenes I need.

 

1.  Create a global variable called "IsItDay".  Create a block scene that sets IsItDay to 1 (or "Yes") when the sun rises.  Create another block scene that sets IsItDay to 0 (or "No") when the sun sets.  Then in my scenes I can start by doing a test to see if IsItDay is 1, and continue the scene if so.  For example, a simple block scene:: If it is 6am, AND IsItDay=0, THEN turn on hallway light.  Of course, you can change the triggering variable to be whatever you want - IsCatInside? AreThereVisitors? IsItSnowing?

 

2. For more complex scenes, you can run everything in a single LUA scene that is continuously looping. An easy way to start LUA is to make a block scene and then convert it to LUA, and tweak it as needed.  At the top of the code you can declare some variables, and either set them to particular values (which you can change during the year), or create some logic to do it automatically. 

 

Here's a code snippet that I use to change how far my blinds open depending on what month it is. First I create a table that contains the value of how far I want the blinds to open in that month.  Then I have a function that will peform the action (ie open the blinds to the correct amount). Lastly, in the main section of code, I am testing to see if the required time is equal to the current time, and call the function if it is true.  The scene is set to run automatically (Under the general tab, "Run scene: Automatically") - this means it is executed once every minute.

 

Some people run their entire home centre using one very long LUA scene.  This can get complex!  On the other hand, having multiple small scenes (even block ones), can make complex inter-dependancies between scenes.  Go with what you are comfortable with - you can use both too of course.


 

Please login or register to see this code.

 

  • 0
  • Inquirer
  • Posted

    Tim_

    OK, got it ..... thanks for the explanations and tips, I'll try here following your guidelines .... thanks!

    could explain a little more how to assemble this part on the moon in your Scene, mainly the 1st part (table). What does it define? I'm not a programmer .....

    I'm in the basics in Lua, making Scenes in blocks converting to Lua and trying to understand the logic.

    thank`s

    • 0
    Posted
    3 hours ago, jorge rintaro said:

    could explain a little more how to assemble this part on the moon in your Scene, mainly the 1st part (table). What does it define?

     

    I've set up my table to list how much my blinds should open (as a percentage) depending on the month.  The first value is month 1 (January), the 12th value is for 12th month (December).  You could use a similar table but put in times, if you wanted to, say, set times to turn on outside lights. eg

    Please login or register to see this code.

    To determine today's on time you use:

     

    Please login or register to see this code.

    To check whether it's time to turn on the lights:

     

     

    Please login or register to see this code.

    The you need to define the function doMyThingFunctionHere().

     

    It's normal to spend a lot of time understanding, playing with the code, and debugging!  Break it down into steps and use a lot of fibaro:debug() commands in your code so you can see what is going on until you get the hang of it.

    • 0
  • Inquirer
  • Posted

    thanks! Tim_,

    I'm going to start the tests here .... thanks for the explanations.

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