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

Adding extra minutes to sunset


Question

Posted (edited)

What I want to do is turn on my lights 15 minutes after sunset.

 

I found the following LUA code at the forum:

Please login or register to see this code.

 

When I try to do this, I get the error: "attempt to perform arithmetic on a nil value". All variables time and sunrise are set.

 

I have no clue what I am doing wrong.

Edited by B_b_B

10 answers to this question

Recommended Posts

  • 0
Posted

I am not sure this is the easiest way but it works for me.

 

Please login or register to see this code.

 

  • 0
Posted

Please login or register to see this image.

/monthly_2021_12/A6803ABC-D7E2-4C44-BE98-71D734F4ED8A.jpeg.027f904129058b44c8eec2bf6a4279df.jpeg" />

  • 0
  • Inquirer
  • Posted

    Not very different from my script? This is what I do:

     

    Please login or register to see this code.

     
    And that ends in an the error "attempt to perform arithmetic on a nil value"
    2 minutes ago, SmartHomeEddy said:

    Please login or register to see this link.

     

    Trigger / condition is not an issue and try to get it working in Lua :)

    • 0
    Posted
    12 minutes ago, B_b_B said:

    Trigger / condition is not an issue and try to get it working in Lua :)


    A6803ABC-D7E2-4C44-BE98-71D734F4ED8A.jpeg.027f904129058b44c8eec2bf6a4279df.jpeg     79895D9C-2B39-4732-B3C5-AF5A1B90D149.jpeg.f15860479874515e3f0684830d3a90aa.jpeg

     

     

    ?

    • 0
  • Inquirer
  • Posted
    1 minute ago, SmartHomeEddy said:


    Please login or register to see this link.

         

    Please login or register to see this link.

     

     

    ?

     

    That will give me the conditions in LUA. Which are not a problem in this case. Scene runs every minute.

    • 0
    Posted

    OK, just thought you wanted to turn on the lights 15 minutes after sunset. 

     

    • 0
    Posted
    18 minutes ago, B_b_B said:

     

    That will give me the conditions in LUA. Which are not a problem in this case. Scene runs every minute.

     

    now depending on what you trying to achive, it might or might not, be useful to trigger every minute to get status of something which happens once a day.

     

    Generally the LUA engine will pre-check the trigger, and no execute any code if condition in not met, so less resources consumption. When you do it as "every minute", the engine will execute the LUA code and check there the value, so more resources used.

     

    So you decide, when you can use "once per day" use condion block and save resources, or if you need every minute (for what so ever reason) use check in code instead. 

    • 0
  • Inquirer
  • Posted
    2 minutes ago, tinman said:

     

    now depending on what you trying to achive, it might or might not, be useful to trigger every minute to get status of something which happens once a day.

     

    Generally the LUA engine will pre-check the trigger, and no execute any code if condition in not met, so less resources consumption. When you do it as "every minute", the engine will execute the LUA code and check there the value, so more resources used.

     

    So you decide, when you can use "once per day" use condion block and save resources, or if you need every minute (for what so ever reason) use check in code instead. 

     

    I am creating 1 Lua script with all time bases actions. As I am using a HC3 Lite, and found that it is not possible to upgrade easily to a HC3 (shame on Fibaro!) I am tied to 20 scenes. I do care less about resources in this case, if needed I can switch from every minute to every 5 minutes of specific triggers. I expect that the Lua scene need to run about 10 times a day with different actions based on the time.

    6 minutes ago, SmartHomeEddy said:

    OK, just thought you wanted to turn on the lights 15 minutes after sunset. 

     

    That is true, but this Lua script has a lot more actions ;)

    • 0
  • Inquirer
  • Posted

    BTW, this is where the code comes from at this forum:

     

    Maybe it is good idea to mention @jgab as he is the author of the original code?

    • 0
    Posted
    22 minutes ago, B_b_B said:

    BTW, this is where the code comes from at this forum:

     

    Maybe it is good idea to mention @jgab as he is the author of the original code?

     

    Yes, but you need to copy the whole scene code otherwise it will not work - the helper functions at the end of the scene are the one that allows you to  do 'tonumber' of a "time string" and thus do the arithmetic. 

    So copy the whole scene and look at the examples.

    • Thanks 1

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