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

10 temperature devices as Child device in a quickapp


PeterB

Question

I have 10 temperature devices (non zwave but 433 Mhz ). I get the data from a get request. I want to make 1 quickapp where all the devices are programmed as a child device . 

My question is, is it possible to create 10 child devices of the same type (temperature device). If so with what of kind of function can I use the  updateProperty to update the temperature value in HC3?

 

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 1

Yes this is possible. Create a table with all your devices and loop though them to create them. Check

Please login or register to see this link.

for great tips.

 

It can be overwhelming when starting into QA coding, so I give you some tips. This is an excerpt from my

Please login or register to see this link.

:

 

Please login or register to see this code.

 

To drill it down:

Please login or register to see this code.

 

Says to the HC3 that the childs are created. This gives you the full manual control over the creation of the childs.

Please login or register to see this code.

 

This checks if there are childs in the parent QA. If not (cdevs == 0) then create them, initChildData is a table to define your childs, in my example you see I use the same type in multiple childs:

Please login or register to see this code.

 

After defining the childs a for loop creates the childs 1 by 1:

Please login or register to see this code.

 

If cdevs was not 0 then there are already defined childs. While creating the childs you saved the className to use in a QA variable. This makes it possible to read the classes for already created childs and initialize them:

Please login or register to see this code.

 

The classes are defined at the top of my QA, for example:

Please login or register to see this code.

 

To update the childs you can simply loop though them and update the values:

Please login or register to see this code.

 

Note: 

You can download my

Please login or register to see this link.

or reaD other community members their code to learn from.
I hope this sets you in the right direction. Happy coding!

  • Like 1
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Many thanks for the elaborate answer. I am reasonable new to HC3 and lua but I look in to it and start trying.

    Is there a way to test my code without polluting my HC3?

    .

     

    Link to comment
    Share on other sites

    • 0

    Yes, use the excellent

    Please login or register to see this link.

    from @jgab with ZeroBrane Studio.

    To get you up to speed fast

    Please login or register to see this link.

     😃

    • Like 1
    Link to comment
    Share on other sites

    • 0

    Wow, this is exactly what I am looking for. I do have one question. Your code 

    On 4/11/2023 at 7:20 AM, Joep said:

    Please login or register to see this code.

    Deals with the children in an all-or-nothing manner. I tend to be more of a pessimist in my coding so I wonder whether to approach this process as "Create the QuickAppChild only if it doesn't aready exist" and deal with each one when you loop through the list. Perhaps I might even go so far as to remove each child from my list. That way when I'm done initializing my current list, I could delete any QuickApChild which hasn't been properly initialized. I fear I might either add more children later or maybe delete the need for one and not remember to clean up after myself.

     

    I also want to say I looked around your site and found a wealth of other good material. I didn't subscribe to your newsletter. It would just get lost in all my email clutter and ignored.

     

    Thanks!

     

    Peter

    • Like 1
    Link to comment
    Share on other sites

    • 0

    This is the easiest way to create children

    Put the library in a separate QA file. It defines a new QuickAppChild class that's named QwickAppChild

    It handles creation and removing of children automatically depending on the table given to self:initChildren(table)
    The trick is that all children should be given a unique identifier so we know if they already exists or are missing.

    In the example, it's the key in the child definition table. Ex. "Child_Temps1" for the first child.

     

     

    Edited by jgab
    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.

    ×
    ×
    • Create New...