Ah, I see now you're not looking at devices/drivers, as I had assumed -- Motion Lighting is a child app of Mode and Motion Lighting. ZMC actually does both -- a child app for each instance, and each of those apps creates a child motion sensor device. That last thing is all I was really thinking about in my response above.
In many cases, a parent app in this case is often little more than a way to "group" related apps. (In others, it serves some app-wide function, like communicating between different child apps, presumably how Rule Machine handles things like "Run rule actions" and pausing/resuming one rule from another.) In this case, it's pretty simple: write the child app more or less like normal, as in your "Switch-Contact" example above, but in its definition
, include a key/value like:
parent: "MyNamespace:MyAppName"
Then, write an app with that namespace and name (spaces are allowed, at least in the app name; other characters get...tricky from what I recall). Somewhere in that app page, you can show child apps and allow creating new ones (this will automatically do both) by writing a line like:
app name: "childAppList", appName: "MyChildAppName", namespace: "MyChildAppNamespace", title: "Add New (child app name)", multiple: true
This goes inside a section
on a page
, just like input
and friends do.
Often with parent apps, you'll also want to add something like this to their definition
:
singleInstance: true,
installOnOpen: true,
This will only let the user install a single instance of the parent (not always desirable, but it often is) and automatically "install' the app when opening, avoiding the need for the user to "Done" or "Install" out of it before it begins permanently residing in the "Apps" list, possibly saving some frustration later if they begin creating child apps before finishing things up with the parent app.
I'm not seeing anything exactly like this in the example, but there should be plenty of community apps. Here's a simple one of mine: Hubitat/apps/TimedSwitchHelper at master · RMoRobert/Hubitat · GitHub
But since you mentioned "events," I assume you may still be interested in devices. The example app above is a bit odd in that it uses a virtual instead of component driver for the child, but I suppose that's still one way you can do this.