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


HC3 QuickApps coding - tips and tricks


jgab

Recommended Posts

On 2/14/2020 at 7:45 AM, jgab said:

Here is an example of using the code for polling for triggers shown in an earlier post

 

This is a QD that looks for an event (trigger) of type 'PluginProcessCrashedEvent' and report that in the QD UI (it will list the 3 last events)

Please login or register to see this link.

Optionally it will do a 'sendPush' to the user ID defined in the device variable (quickVariable) 'pushID'.

 

This is very handy as it will easily give an overview what devices are crashing as you experiment with coding. When debugMessages for scenes will start to work we could easily extend the DQ.

 

QD's that crash will be automatically "restarted" after a ~minute by the system so there will be additional crashes - an extension would be to not push repeated errors.

 

Please login or register to see this attachment.

Hi @jgab,

How could the LV "enabled" becoming true in CrashNotifier? Is has been set to NOT enabled = false once and then never be set to true again ?‍♂️

Link to comment
Share on other sites

  • Topic Author
  • 35 minutes ago, Rover said:

    Hi @jgab,

    How could the LV "enabled" becoming true in CrashNotifier? Is has been set to NOT enabled = false once and then never be set to true again ?‍♂️

    LV? What is that? Do you get some error message? 

    What is enabled? the QA CrashNotifier?

     

    You have to explain a bit more to us that is not so deep into this stuff....

    Link to comment
    Share on other sites

    2 hours ago, jgab said:

    LV? What is that? Do you get some error message? 

    What is enabled? the QA CrashNotifier?

     

    You have to explain a bit more to us that is not so deep into this stuff....

    Please login or register to see this spoiler.

     

    Link to comment
    Share on other sites

  • Topic Author
  • Posted (edited)

    Ok, so this is code since February last year so my memories are not that strong. I think that @petrkl12 made a version of it that doesn't use the annoying TICK hack...
    Anyway,  at that time the. UI model was changing a bit.  They used to default to buttonID + "Clicked" for the Lua handler.

    This doesn't work anymore. 

    The UI button was supposed to toggle the enable variable when pressed.

    If you open the QA and in the button editor add

    'enableClicked' in the onReleased input field (without the '') the button should call the QuickApp:enableClicked() function that toggles the LV enable.

    Edited by jgab
    • Thanks 1
    Link to comment
    Share on other sites

    8 minutes ago, jgab said:

    Ok, so this is code since February last year so my memories are not that strong. I think that @petrkl12 made a version of it?
    Anyway,  at that time the. UI model was changing a bit.  They used to default to buttonID + "Clicked" for the Lua handler.

    This doesn't work anymore. 

    The UI button was supposed to toggle the enable variable when pressed.

    If you open the QA and in the button editor add

    'enableClicked' in the onReleased input field (without the '') the button should call the QuickApp:enableClicked() function that toggles the LV enable.

    Yes @jgab ?

    Link to comment
    Share on other sites

    1 hour ago, jgab said:

    Ok, so this is code since February last year so my memories are not that strong. I think that @petrkl12 made a version of it that doesn't use the annoying TICK hack...
    Anyway,  at that time the. UI model was changing a bit.  They used to default to buttonID + "Clicked" for the Lua handler.

    This doesn't work anymore. 

    The UI button was supposed to toggle the enable variable when pressed.

    If you open the QA and in the button editor add

    'enableClicked' in the onReleased input field (without the '') the button should call the QuickApp:enableClicked() function that toggles the LV enable.

    newest version of Crash_Notifier.fqa :)

     

    Please login or register to see this attachment.

    • Thanks 1
    Link to comment
    Share on other sites

    11 minutes ago, petrkl12 said:

    newest version of Crash_Notifier.fqa :)

     

    Please login or register to see this attachment.

    That's quite a reconstruction! TNX @petrkl12 ?

    Link to comment
    Share on other sites

    W dniu 31.03.2021 o 14:18, michal85pl napisał:

    Hello,

     

    After last updates of HC3, proxy stopped working...Am I the only one who has a problem?

     

    W dniu 1.04.2021 o 16:36, michal85pl napisał:

    Unfortunately there is a problem with HCL> HC3 communication, HCL does not send any messages to HC3. HC3 reads devices and values at the start of QA, enables switching on of switches, but does not receive feedback that a given switch changed state or motion was detected.

    @jgab do you know anything about this problem?

    W dniu 1.04.2021 o 20:37, michal85pl napisał:

    Rolling back to version 5.050.13 and everything works as it should ... Unfortunately, HCL debug doesn't work anymore, so I can't tell what it's reporting ..

     

     

    I repeat my query

    Link to comment
    Share on other sites

    Here is a tip on how to hide/unhide button in QA:

     

    Please login or register to see this code.

     

    • Like 2
    Link to comment
    Share on other sites

  • Topic Author
  • Posted (edited)
    17 minutes ago, michal85pl said:

    I repeat my query

    No, I have no idea. I have never tested it on a HCL and would not dare to guarantee anything as the HC2 proxy uses some tricks and I.  have no idea what the HCL supports - and they may have changed something.

    Besides that I've moved completely over to the HC3 so I haven't run this code for 6+month.

    I would be happy if someone with a HC2 (and HC3) took over an evolved it.

    It's a good architecture where the proxy on the HC2 only pushes changes to the child devices on the HC3 - no constant polling creating unnecessary traffic. A "production grade" bridge/slave-function should probably use a similar model.

    5 minutes ago, petrkl12 said:

    Here is a tip on how to hide/unhide button in QA:

     

    Please login or register to see this code.

     

    Yes I saw that too.

    It leaves an ugly gap in the UI :-)

    I would have liked something that disabled the button - grayed it out - so that users knew it was. disabled.

    Edited by jgab
    Link to comment
    Share on other sites

    Jan I have a QA with ID 829 and two buttons

    how to action butto 1 or 2?  ChangeActivityState does not work.
        

    //Sjakie

    Link to comment
    Share on other sites

  • Topic Author
  • 42 minutes ago, Sjakie said:

    Jan I have a QA with ID 829 and two buttons

    how to action butto 1 or 2?  ChangeActivityState does not work.
        

    //Sjakie

    If it is a QA and you can open and view the code in the editor.

    The buttons have actions associated with them (viewable in the UI element editor).

    The 'action' name for the button is typically handled by a function. ex. if the action was 'turnOn'

    it is handled by the function

    function QuickApp:turnOn(...) .... end

     

    If you have located the right function you can then call that action from another scene/QA with

     

    fibaro.call(QA_ID,"turnOn")

     

    That's the easiest way but requires some detective work.

    Link to comment
    Share on other sites

    Jan Thanks! Regretley I cant open the QA it does not view their code.

    Its comming from a plugin or QA with childs

    //Sjakie

    Link to comment
    Share on other sites

  • Topic Author
  • 3 minutes ago, Sjakie said:

    Jan Thanks! Regretley I cant open the QA it does not view their code.

    Its comming from a plugin or QA with childs

    //Sjakie

    If it's a QA with children the code is in the mother QA.

    Link to comment
    Share on other sites

    Nope I checked that too.

    snif, snif

    Harmony plugin

    //Sjakie

    Link to comment
    Share on other sites

  • Topic Author
  • 6 minutes ago, Sjakie said:

    Nope I checked that too.

    snif, snif

    Harmony plugin

    //Sjakie

    which button do you want to press? I can have a look here.

    Link to comment
    Share on other sites

    Jan there are two buttons

    start

    stop

    Please login or register to see this image.

    /monthly_2021_04/afbeelding.png.8fbc81a0ee9da29d42e51352f44884c1.png" />

    Link to comment
    Share on other sites

  • Topic Author
  • Posted (edited)
    On 4/15/2021 at 11:52 PM, Sjakie said:

    Jan there are two buttons

    start

    stop

    Have you tried:

    Please login or register to see this code.

     

    or even

    Please login or register to see this code.

    ?

    Edited by jgab
    Link to comment
    Share on other sites

    Jan,

    Regretly no action on TV.

    See also the other post

    Link to comment
    Share on other sites

    • 5 weeks later...
  • Topic Author
  • Here is a hack with quickAppVariables

    Please login or register to see this code.

    suitable to be put in a library file.

    It "fixes" 3 things.

    1. quickAppVariables are accessed as keys in self.vars. Ex. print(self.vars.x)

    2. Non-existent variables return nil instead of ""

    3. It's much faster to access variables as they are just table key accesses instead of searching linear in a list...

     

    Note that to create a quickAppVarible, one need to explicitly use self.vars:create(name[,value])

    Setting a variable (self.vars.x = 99) is still using self:setVariable to make sure that the change is persisted.

    Could probably be made faster by using our own updateProperty('quickAppVaribles',...)

     

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