Composite Devices (Parent-Child Devices)

there any way to access parent Settings or attributes from a child device?
something like
the specific need is im trying to do a asynchttpGet from a child device but the ip,port,api key is store on tha parent device.
I could pass the information on creation to the child device and store it to use but it will be storing duplicate information.

a child can call

in the parent method() can return values.

Depending on frequency, this can be a lot of overhead.

Better is the parent to call child.methodA(), and the child store it.

If all children share the same settings, you can use @Field static .... in the child to define a shared variable that all children (if using the same source file) share. This both avoids state variables (DB accesses), and lot of children calling the parent, etc...


Just something to consider when designing a Composite Device...

Typically, the child devices are very lightweight, simple devices (similar to a virtual device). They will usually call a method of the Parent device to handle any real communications with the real world. This keeps all of the 'real code' local to the parent device, which already has access to all of the data needed to perform the necessary Zigbee, Z-Wave, or LAN/WAN communications.


I decide pass the responsibility to the parent device and leave the child as light as possible thanks for the fast response @ogiewon @nh.schottfam

1 Like