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

Quickapps OnInit


Question

Posted

When is OnInit triggered in a Quickapp.
I've been testing and debugging but it's triggered by saving the code or by opening the quickapp.

 

I have a quickapp that needs to get some variables when the quickapp opens so i put that code in the "function QuickApp:onInit()".

When i open the app the variables are not updated.
Sometimes i see in the debugger that it runs but i don't know how it works.

@jgab maybe ? 😉

 

5 answers to this question

Recommended Posts

  • 0
Posted
9 hours ago, Lode said:

When is OnInit triggered in a Quickapp.
I've been testing and debugging but it's triggered by saving the code or by opening the quickapp.

 

I have a quickapp that needs to get some variables when the quickapp opens so i put that code in the "function QuickApp:onInit()".

When i open the app the variables are not updated.
Sometimes i see in the debugger that it runs but i don't know how it works.

@jgab maybe ? 😉

 

Every time you save the QA (even if you just added a space character) it will read in all the files of the QA and when done it will call your QA's :onInit(), if you have one.

When the QA crashes with an error it will also re-read in the QA and call :onInit(), same way as when you do save. For errors it will wait 30-60s before loading the QA again so an error will not cause an avalanche of error messages in the log...

It will not load the QA again if you just open and then close the QA editor.

  • 0
  • Inquirer
  • Posted

    @jgab Thanks again for stealing your valuable time.

     

    Everytime i open the Quickapp it needs to update some values.

    So how can i do that ? If it's even possible ?

     

    I have a scene that runs every minute so i could call the OnInit function every minute but that's not the proper way to do it i think.

    • 0
    Posted
    1 hour ago, Lode said:

    @jgab Thanks again for stealing your valuable time.

     

    Everytime i open the Quickapp it needs to update some values.

    So how can i do that ? If it's even possible ?

     

    I have a scene that runs every minute so i could call the OnInit function every minute but that's not the proper way to do it i think.

    You mean "view" in the Yubii app?

    If you need to update a label or variable in the app you either do it scheduled (ex. every minute) or you do it when 

    the external factors that make you need to change the variable/label changes. Ex. if your variable/label should show the remaining charge of an external device, you update the label/variable when the device reports that it's power has changed.

    • 0
  • Inquirer
  • Posted (edited)
    1 hour ago, jgab said:

    You mean "view" in the Yubii app?

    If you need to update a label or variable in the app you either do it scheduled (ex. every minute) or you do it when 

    the external factors that make you need to change the variable/label changes. Ex. if your variable/label should show the remaining charge of an external device, you update the label/variable when the device reports that it's power has changed.

     

    Yes, the view in the Yubii app.

    I will do it scheduled, for me the most convenient way.

     

    As far as i remember there was a code section for the VD in HC2 that runned every minute.

     

    Thanks again 😉

    Edited by Lode
    • 0
    Posted

    Please do not run the OnInit every minute (as I read your previous post correctly, you want to do that). OnInit is the start of the "program". Make a new function to update the data and schedule to run that function every minute.

     

    For example:

    Please login or register to see this code.

     

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