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 scripts not scheduled


Guest erkadevil
 Share

Question

Guest erkadevil

Hello,

 

My LUA-scenes are not being rescheduled on Home center 2. They run once when I click "start" or "run" but never runs again. 

This has worked fine before and just seem to have stopped working all of a sudden.

Even if I create a new scene with just at debug printout, nothing happens more than once.

It might be related to a firmware upgrade, I'm not what version of the firmware that this was running properly on. Now I use the latest version (4.042).

 

Any clues to what's going on and how I can get things going again?

 

BR

Erik

Link to comment
Share on other sites

17 answers to this question

Recommended Posts

  • 0

Hello,

 

My LUA-scenes are not being rescheduled on Home center 2. They run once when I click "start" or "run" but never runs again. 

This has worked fine before and just seem to have stopped working all of a sudden.

Even if I create a new scene with just at debug printout, nothing happens more than once.

It might be related to a firmware upgrade, I'm not what version of the firmware that this was running properly on. Now I use the latest version (4.042).

 

Any clues to what's going on and how I can get things going again?

 

BR

Erik

I you post the script code maybe we can help you ......

Link to comment
Share on other sites

  • 0
Guest erkadevil
  • Inquirer
  • I you post the script code maybe we can help you ......

     

    Even if I just write a short script with a debug printout it won't run repeatedly.

    But one script that has worked is shown below (It is supposed to set a variable for light condition).

     

    Please login or register to see this code.

    Edited by erkadevil
    Use code tags, it makes code more readable
    Link to comment
    Share on other sites

    • 0

    post your script that doesn't run..... 

     

    the one you posted above will be triggered by a device with id 12, how do you let the scene trigger that doesn't run?? 

     

    cheers

    emiel

    Link to comment
    Share on other sites

    • 0

    I'm new to Fibaro, bought HC2 and having some problems with scenes, works sometimes, sometimes don't work... don't get it.

     

    I'm also using FW 4.042, and have this script that sets the Variable 'Dia_Noite' = Noite, everyday 60m before sunset, but it's not working :/

     

    Here's the lua script:

    Please login or register to see this code.

    Do you know why this variable was not set?

    Thanks.

    Link to comment
    Share on other sites

    • 0

    @erkadevil, what is the device with id 12?

    @Morcegolas, I cleaned it up a little bit, put some debugs inside to make sure it runes properly, you can also print those times you are checking.

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0

    Hi 

    Please login or register to see this link.

    ,

     

    Able to enlighten me for your scene, which is the trigger function? and what does the autostart means? Is this scene running infinite?

    Link to comment
    Share on other sites

    • 0

    autostart means that scene will be run at the boot up of gateway (also when saved for example), there is no trigger, because there is infinite loop (tempFunc runs itself in some time - setTimeout function).

    Link to comment
    Share on other sites

    • 0

    @j.nowacki, with your scene it worked, at least the first time, now I'll ask you to do the same but instead of some time after or before the sunset I want to do at exact time 22:00H and variable is set do 'Discreto'

     

     

    This is my script made with blocks:

    Please login or register to see this code.

    The only thing I think its strange it's that I created this simple scenes with blocks and they should work, but they don't. :/

     

    Already tried to change to this but it don't work:

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0

    All you need to do is change this 'if' instruction:

    Please login or register to see this code.

    just change the hour you are waiting for (e.g. '22:00' ) and the line where variable is being set.

    Link to comment
    Share on other sites

    • 0

     

    I did this but it didn't worked:

    Please login or register to see this code.

     

    You basically checked something like this:  if (current time == current time == 22:00) - do you see the problem here?

    Just try:

    if os.date("%H:%M", os.time() ) ==  "22:00" then

    Link to comment
    Share on other sites

    • 0

    OK, got it. Sorry but I'm really new to this. I'll do some search in how to programming in lua.

     

    I didn't know that:

    os.date("%H:%M", os.time() )

     

    and:

    string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min)

     

    was the same ( current time ).

     

    But it's strange that with second option its not working, for people like me that are starting, the blocks is much easier,( I already realised that it's way more limited ) but that way was not working. Now I have try some times and its working (Y).

     

    So maybe there's a bug with blocks in FW4.042 I don't know. :/

     

    Thanks for helping out!

    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" />

    Link to comment
    Share on other sites

    • 0

    I have 3 scenes to control this Variable, I deactivated them and add one with equal to the ones you told me only changing the if condition, it seams to be working, should I change anything or is it ok like this?

    Please login or register to see this code.

    Thanks.

    Link to comment
    Share on other sites

    • 0

    autostart means that scene will be run at the boot up of gateway (also when saved for example), there is no trigger, because there is infinite loop (tempFunc runs itself in some time - setTimeout function).

    Does the infinite loop eat up the ram usage by alot? From your timeout of 60 * 1000 which is 60 seconds. Is this the recommended timeout for HC2 to operate normally?

    Link to comment
    Share on other sites

    • 0

    Does the infinite loop eat up the ram usage by alot? From your timeout of 60 * 1000 which is 60 seconds. Is this the recommended timeout for HC2 to operate normally?

     

    This is the advantage of setTimeout() over fibaro:sleep(), it does not consume any additional resources, so it is safer to use setTimeout() even with few seconds of delay, than putting scene to sleep.

     

    @Morcegolas it seems all right for me, let me know if something is not working as expected.

    Link to comment
    Share on other sites

    • 0
    Guest erkadevil
  • Inquirer
  •  

    @erkadevil, what is the device with id 12?

    @Morcegolas, I cleaned it up a little bit, put some debugs inside to make sure it runes properly, you can also print those times you are checking.

    Please login or register to see this code.

     

    Hmm ok, I guess that I wasn't really sure about the syntax here.

     

    So what you say is that putting the line

    "12 value"

    at the top will make the scene trigger on device ID12?

     

    /Erik

    Link to comment
    Share on other sites

    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.

     Share

    ×
    ×
    • Create New...