Easy way to know if Parent or Child app in groovy?

Looking to see if there is a quick and easy way to know if this is a parent or child app within the code.

example:

If(parentApp) {
     log.info "this is a parent app"
} else {
     log.info "this is a child app"
}

Thanks

You can use the built-in getParent() method in apps or drivers, then if it returns something that isn't Groovy-false, you know it's a child app or device. (But keep in mind that devices can also be children of apps, so it doesn't necessarily mean the device has a parent device--but since you're only asking about apps, that isn't a concern.)

I'm not aware of a way to check in the other direction other than to check if there are children, which could be what you're looking for but will only work if there are any, not if the code makes it capable of being so. (Along those lines, I'm not really sure what you are looking for, or maybe there's a better way to look at the whole situation.)

Thanks. Just trying to show something in the footer of my apps. If it's a parent, then show "this line". If it's a child app, show "that line".

Don't care about devices or even if there are children yet. Just if it's a parent or child app.

Hopefully that makes better sense.

I can add something in the code to distinguish between the two, but wanted to see if there was a built in way first.

Download the Hubitat app