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 running in main loop but not in a button???


Question

Posted

Hi

 

I have some code which is running fine in the main loop but when I copy the EXACT code into a button it does not run at all...

the debug screen stays blank.

 

Is there a difference in handling between those except one rinning in loop?

 

Example of the code:

Please login or register to see this code.

 

7 answers to this question

Recommended Posts

  • 0
Posted

Lua code runs in main loop only.

To run the code in button, you need to press the button. This is the hole idea of having buttons.

  • 0
  • Inquirer
  • Posted (edited)

    Yes I understand of course ;D

    But it does not run when pressing the button too!!

    and yes, the "lua" is marked

     

    Edited by twannieguitar
    • 0
    Posted

    No errors also?

     

    • 0
    Posted (edited)

    I'm trying to understand you code and looks like the code runs OK, but you did some strange case

    if (nano == nil)

    then nano = Net.FHttp(ipAdress,port)

    else

    ...

    ...

    end

    Since when you press the button nano is NIL, so nothing executed

    Please try as follow

    Please login or register to see this code.

    Edited by cag014
    • 0
  • Inquirer
  • Posted

    i think i know... i did some testing but it has to do with 

    Please login or register to see this code.

    The main loop memorizes "nano" as a global value...  a button is local!

    • 0
    Posted

    Yes, this is correct

    • 0
  • Inquirer
  • Posted

    thanks for thinking with me

    That line wass still in there from original device...

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