Programmatically populate devices? (Composite devices / Child devices)

I'm working on getting a custom driver working for my Honeywell thermostats via they Total Connect Comfort API. I started with existing code for SmartThings (which csteele took a pass at converting for Hubitat). Turns out this code is a mess and I'm not sure if I'll keep it as a starting point or just start again from scratch. Regardless, I'd like to figure out if I can programmatically populate the devices.

I have 5 of these thermostats (mini-split setup with 5 heads) and manually populating them is an ugly process of scraping device IDs from the Honeywell website and putting in my credentials 5 times. It would be a lot cleaner to enter my credentials once, "discover devices", and have it create the virtual thermostats for me. I also would like to share some amount of state (specifically auth tokens) between devices.

Is there a way to support this sort of "driver/app" that can create virtual devices semi-dynamically and manage their shared state efficiently?

edit: I see that there is support for "composite devices", which seems relevant. Looking into that now. You guys need better docs. :slight_smile:

1 Like

Composite devices looks like what I need for this specific piece. In case anyone else finds this later, here's the reference I found:

Along with a helpful example:

1 Like

Let me know when your driver is ready. I don't need more than that driver I found, but I can test a better one easily enough :slight_smile:

Will do. That one seems pretty sloppy. It performs a login for every action, along with a lot of duplicated code. :\ I haven't worked out how I should maintain login state yet in a HE driver yet, but I'm confident that re-authenticating on every request is not the proper way to do it.

Honeywell actually has a public API now, but it looks like they only support it for Lyric thermostats. My Total Connect Comfort account is bounced with a "not recognized" error, which is disappointing. Sticking with reverse-engineered TCC, I guess.

https://developer.honeywell.com/api-methods?field_smart_method_tags_tid=39

I have clicked a few buttons when I first found it but mostly I need to flip between Heat-Off-Cold since that's not covered in my Thermostat's programming. I guess that means I use the driver twice a year. I'm not sure the "extra" login hurts much :smiley:

For anyone else wanting to do this, here's a super-stripped down example of a composite (parent/child) driver. The parent has a single command (recreateChildDevices). It creates two devices that present as switches (but no-op). So it's a skeleton to plug into.

Add the parent and child driver code and then create a virtual Parent device. Once completed, you'll see the two children nested under the parent in your devices page.