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 script to set time of day variable really unstable


Question

Posted

I'm using a variable to turn on/off garden lights. One lua script loops continuesly and checks the system time every 55 seconds. If it is evening a variable is set to evening and the same for morning. Another lua script reacts one the variable change and turns on/off the garden lights.

It is really straight forward, trivial even. But I can't rely on it because it fails a lot. The problem is that the variable sometimes is not updated. So it stays dark outside.

I'm using 4.042. It worked great on version 3.5x. Any ideas? Where can I find a log?

3 answers to this question

Recommended Posts

  • 0
Posted

I use this to set the time period of the day, never missed:

Please login or register to see this code.

Now you can use these variable in other scripts.

  • 0
  • Inquirer
  • Posted

    Thank you for posting your lua script. Mine looks pretty similar. In addition I check sunset hour and sunrise hour with these calls fibaro:getValue(1, "sunsetHour") and fibaro:getValue(1, "sunriseHour"). I noticed I check these values every minute, so I'm going to optimize the lua script. I don't know if these values are retrieved each time, calculated each time or if there are cached per day. Maybe anyone from Fibaro can elaborate on this? But it might be just the cause to why my scripts dies every couple of days.

    • 0
  • Inquirer
  • Posted

    Boerremk, I'm now using your script, but this evening again the garden lights did not go on. The global variable was at 21:36 still 'morning', while it should have been 'evening' obviously.

     

    Is there a log file somewhere I can check? The debug windows does not help. It just displays the last set state, which is 'morning'. The script just seems to die after having run perfectly fine for a couple of days.

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