Component Child Device with unique icons

I have built a custom DTH using the new Component child device structure. In my parent DTH I display all the child devices as shown in the picture below. I would like to display a unique icon for each child. Is this possible?
I have tried to specify icons as follows:

childDeviceTile("fanLow", "fanLow", icon: "locationOfPictureHere")

But it always displays the icon specified in the child DTH.

1 Like

@rajk wrote the composite devices documentation, and is currently working on documentation for the childDeviceTile. Raj can you answer this question?

1 Like

can the number of childDeviceTiles be programatically adapted to a variable number of child devices?

I’m not sure what you are asking, but there are 2 ways that I know to display child tiles.

  1. display each tile individually using the componentLabel
    childDeviceTile("referencename", "componentLabelGoesHere") details("referencename")

or
2. display all associated device tiles
ChildDeviceTiles("referencename") details("referencename")

Thx Stephan. I do not know in advance how many childdevices i need to create (can be up to 10). I could not find the documentation for the above. But looking at your answer if i use option 2, it will display all childs that i create under the parent device, this would meet the reqs i need.

Yes the 2nd option will do what you need. What you see in the pic of my original post is the second option which includes all the associated child devices (including 2 separate child DTH’s - one for the lamp and another for all the fan modes).

I would like to have a different icon for all the fan modes, which if possible, would probably require me to specify each child individually using option 1.

1 Like

Stephan,

The childDeviceTile() method does not yet support specifying icons. It’d always pick up the icon defined in the child Device Handler.

(Aside: By the way, personally I find your way of using your Bedroom Fan details view interesting, i.e., setting up a button each for various fan speeds.)

3 Likes

Yeah…I’ve been working with @dalec and @ranga on a zigbee fan handler and the composite device type came just in time to open up a lot of possibilities. We had to pretty much rewrite the dth but it was worth it for the benefits and options the new type provided. We look forward to more documentation on this so there would be less guess work. Thanks for your work on this so far.

1 Like

You could create unique child device handlers, each specifying a unique icon.

1 Like

Correct. This is one way, though it can get tedious real fast.

1 Like

I could but the question is…should I? That would be a lot of work to maintain and a lot of instructions for users to follow. The unique icons are important enough for the extra work.

Plus it would make for an awefully cluttered IDE :wink:

1 Like

True, but with Github integration, it is easy to maintain many Child Device Handlers. I am already up to 13 for my ST_Anything Arduino/ESP8266 project.

You could also set the “canChangeIcon” to true so they can pick the icon for each child, but I am guessing you want custom icons? Plus, it would be annoying for the users to set this up.

These require 5 fan children and 1 light child. Because it makes the thing page cluttered we do not have the fans exposed to the thing view, so unfirtunately there is no place to allow changes to the icons. The light child is exposed and allows for icon changes.

Stephan,

Hmmmm??? I just did a quick test where I changed my Parent DH to use “isComponent: true” when adding Child Devices. I added a child and was still able to change the icon manually by selecting the child device, which takes me into the full child DH view, then selecting the gear icon, and finally updating the icon. This icon is then displayed in the Parent’s list of children.

Not sure if this helps or not???

Just another data point.

Dan

Are you selecting the child device from the main things page that list all your ST devices? I ask because if you set isComponent to true it shouldnt show on the main thing view at all.

Correct. I can only see the child within the parent. I can then select the child, which takes me into the child’s view. From here, the child looks like any other standard device.

In my Parent DH, I include the list of children with the childDeviceTiles(“all”) command as follows. Maybe that makes a difference?

	// Tile Definitions
	tiles (scale: 2){
		standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 6, height: 1) {
			state "default", label:'Refresh', action: "refresh.refresh", icon: "st.secondary.refresh-icon"
		}
        
		standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat", width: 6, height: 1) {
			state "configure", label:'Configure', action:"configuration.configure", icon:"st.secondary.tools"
		}

		childDeviceTiles("all")
	}

You can take a look at my Parent and Child DH’s in my github repo at https://github.com/DanielOgorchock/ST_Anything/tree/master/devicetypes/ogiewon

Note: The version in GitHub has “isComponent: false” as that is what is desired for my application.

Hmmm…Thats how my parent DTH is setup as well. I use the childDeviceTiles (), but clicking on the child tiles does nothing for me. Strange.

Did you delete and recreate the child devices when you tested?

I just ran another test.

I modified my Parent to use isComponent: true, saved, and published.

I then deleted the Parent Device from within my phone’s ST App (causing all children to be deleted as well.)

I then manually created a new device in the ST IDE, and assigned it to my Parent DH.

The new Parent showed up in my phone’s “Things View”.

In my case, I then have to configure the parent using the “gear icon” to assign it some critical LAN data so it can talk to the NodeMCU ESP8266 board running my custom ST_Anything firmware. After clicking done on the Parent’s config page, a “Refresh” command is sent to the NodeMCU board causing it to send status updates for every component wired to the board. These status updates cause the Parent DH’s parse() routine to look for corresponding child devices. If they are not found (which they aren’t on the first status update after creating the parent) the parent DH creates a corresponding Child Device using the appropriate Child DH.

At this point, I now have many child devices listed ONLY in the parent’s view, not in the All Things view. Clicking on any of the child devices within the parent takes me into the Child DH’s view, where I can click the gear icon to configure that child.

I am using an iPhone to run the ST Phone App. Maybe it’s different on Android?

1 Like

Yup…that’s what it was. I tried on my Ipad and it allows me to view the details when I tap on each child. Gotta love the android/ios discrepencies.

2 Likes

We both learned a little something tonight! Thank you for sharing your new Composite DH with the community. I am really enjoying seeing how everyone is making use of this awesome new feature!

1 Like