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


Question

Posted

Hi all,

I am trying to make a scene that runs 4 times a day every day, but only when 2 global variables have certain values:

 

Please login or register to see this spoiler.

The problem is this scene doesn't run at the specified times even if the 2 variables conditions are met.

 

Any idea of what I am doing wrong?

 

Thanks!
Riccardo

8 answers to this question

Recommended Posts

  • 0
Posted (edited)

@rcanetta

Should this scene only start if the globals reach the values? or should the scene start at the times and then only if the globals have the values?

 

You can try this one. 

Because I run this scene every 5 minutes, I have run the times between 9 am and 9:05 am. If I put it at exactly 9 o'clock you have the chance that it will miss the time.

Please login or register to see this spoiler.

 

Edited by Reinhold
  • 0
Posted

You can use modulus math to fix this, and make your code small and clean.

You want to run the event 4 times in 24 hours. That is every 6 yours.

Run the scene every minute and use the code:

Please login or register to see this code.

 

  • 0
Posted (edited)
6 hours ago, Joep said:

You can use modulus math to fix this, and make your code small and clean.

You want to run the event 4 times in 24 hours. That is every 6 yours.

Run the scene every minute and use the code:

Please login or register to see this code.

 

If you run the scene every minute you will get a hit 60 times every 4 hour...

 

Please login or register to see this code.

 

Edited by jgab
  • 0
  • Inquirer
  • Posted

    Hi all,

    thanks a lot for helping - at the end I have fixed it to do exactly what I want by converting again a scene from blocks to LUA and leaving the 2 "copies" of the same process (which I don't understand why it's needed)

     

    Anyway, this is the code

    Please login or register to see this code.

    Thanks again!!

    Riccardo

    • 0
    Posted (edited)
    11 hours ago, rcanetta said:

    Hi all,

    thanks a lot for helping - at the end I have fixed it to do exactly what I want by converting again a scene from blocks to LUA and leaving the 2 "copies" of the same process (which I don't understand why it's needed)

     

    Anyway, this is the code

    Please login or register to see this code.

    Thanks again!!

    Riccardo

     

    Good that you found a solution that works for you.

     

    Be aware though that there is an issue with this kind of auto generated code from block scenes (and block scenes) - if you are unlucky you may miss an interval.

    The tempFunc() will drift a ~1ms every 13min (the time it takes to execute the tempFunc() in this case - I did some simple benchmarking, it may be a bit more or less)

    That means that if the clock is close to a border between minutes, ex. 08:59:59:999 and you add 1 minute for the next interval 09:00:00:999, but you then get that extra millisecond, you actually have 09:01:00 and it will not match 09:00...

     

    Granted you have to be a bit unlucky to start that close to a border. With 1ms every 13min you will drift 1 minute in ~540 days. So on average every 270th day  and a 4/24 chance to affect one of the 4 times you test against. That's a low chance but better odds than most lotteries..

     

    Sometimes you hear people saying that their scene worked for weeks and then one morning the lights didn't turn on... this could be one explanation.

     

    However, in your case it may not be disastrous if you miss one interval.

    Edited by jgab
    Wrong calculation, odds improved.
    • 0
    Posted
    14 hours ago, jgab said:

    If you run the scene every minute you will get a hit 60 times every 4 hour...

     

    Whoops! ☺️

    In my head I was working with minutes, and the script looks at the hours. Thank you for pointing it out. ?

    • 0
  • Inquirer
  • Posted

    thanks a lot for the drift explanation, very clear - yes, missing one it's not an issue but I will know why if it happens!!

     

    Thanks!
    R

    • 0
    Posted

    I know you solved your problem.

    However I've just posted a timer scene that "extends" ordinary scenes with a "%% time" header to schedule the start of a scene at specified times.

     

    Your scene would look like this then

    Please login or register to see this code.

    times/sunset/sunrise/days and months can be easily specified.

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