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


Recommended Posts

Posted (edited)

Jan, can you please check this..

It throws me error when updated to latest Fibaroextra, and it was working months before update.

 

Please login or register to see this code.

main.lua:15: attempt to call a nil value (field 'event')

Edited by Neo Andersson
Posted (edited)
27 minutes ago, Neo Andersson said:

Jan, can you please check this..

It throws me error when updated to latest Fibaroextra, and it was working months before update.

 

Please login or register to see this code.

main.lua:15: attempt to call a nil value (field 'event')

 

Well, you were lucky in the past. 

fibaro.event(...) should not be used before QuickApp:onInit() is called. The reason is that the order of the loading of the files of the QuickApp is not guaranteed.

If 'main' is loaded before 'fibaroExtra' you can't call fibaro.event(...) on top-level in 'main' because fibaro.event(...) is not defined yet.

 

The way to do it is either lifting in the code above inside QuickApp:onInit() or wrap it in a function called from :onInit()

Ex.

 

Please login or register to see this code.

 

Edited by jgab
  • Topic Author
  • Posted
    3 minutes ago, jgab said:

     

    Well, you were lucky in the past. 

    fibaro.event(...) should not be used before QuickApp:onInit() is called. The reason is that the order of the loading of the files of the QuickApp is not guaranteed.

    If 'main' is loaded before 'fibaroExtra' you can't call fibaro.event(...) on top-level in 'main' because fibaro.event(...) is not defined yet.

     

    The way to do it is either lifting in the code above inside QuickApp:onInit() or wrap it in a function called from :onInit()

    Ex.

     

    Please login or register to see this code.

     

    ohh okay, thanks, i think i cant update all my QAs to latest Fibaroextra..as i used event function calls many times like in the example...

    Posted
    2 minutes ago, Neo Andersson said:

    ohh okay, thanks, i think i cant update all my QAs to latest Fibaroextra..as i used event function calls many times like in the example...

    Well, if you do that you are playing file-order-roulette and your existing QAs may start to throw errors at restarts. You have just been lucky so far.

    Just now, jgab said:

    Well, if you do that you are playing file-order-roulette and your existing QAs may start to throw errors at restarts. You have just been lucky so far.

     

    It's actually a general rule when developing QAs. If you have a multi-file QA, don't use functions defined in the other files until your QuickApp:onInit() has been called.

    • Like 1
  • Topic Author
  • Posted
    2 minutes ago, jgab said:

    Well, if you do that you are playing file-order-roulette and your existing QAs may start to throw errors at restarts. You have just been lucky so far.

     

    It's actually a general rule when developing QAs. If you have a multi-file QA, don't use functions defined in the other files until your QuickApp:onInit() has been called.

    Thank you for the advice..

    • 2 months later...
    Posted

    ]9873

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

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