I’ve seen a lot of talk about parent child apps in the same source file (I think, could be miss understanding). How is this accomplished? The example from ST seems to talk about different files. Any good examples to look at?
CoRE and Ask Alexa use a single app.
I believe I saw someone from ST say they don’t officially recommend it.
I looked at CoRE already this morning. It wasn’t apparent which where the parent ends and child begins. It is massive.
@ady624 is very helpful and can probably point you in the right direction
It also looks like Ask Alexa uses separate apps…
Ask Alexa started as two, but he moved it to one.
Nest Manager uses it. The problem is the last android client update changed something that after a child app is installed and you open it again once you close that child app it returns you directly to the main smartapps page instead of the parent smartapp
it’s all about the name definition:
definition(
name: parent ? "Whatever Child Name" : "Whatever Parent Name"
)
Then create a startPage:
def startPage() {
if (parent) {
childStartPage()
} else {
parentPage()
}
}
Since there is only one definition section per app, if the parent and child are in the same file, so I don’t need something like this…
parent: "mynamespace/parent:Simple Lighting"
The parent metadata is not necessary
Any advice? When I attempt to install the app, I get to a page where it says “New Child App” >
I press that button an I get a spinner, but nothing happens. I’ve taken a look at your code in an attempt to figure this out. I think I am matching it, but you have a lot there.
Sorry i just seen this… I’m reviewing now
try moving the name metadata to a variable
name: "${appName()}",
//This performs the check and returns as a string
//The appName below is exactly how I use it and it works for me
private def appName() { return "${parent ? "The Child" : "Test Parent Child App"}" }
Here is an example of the input for my nest automations app.
app(name: "autoApp", appName: appName(), namespace: "tonesto7", multiple: true, title: "Create New Automation..."
I would also modify your installed(), update(), and initialized() methods to handle the parent versus child functions
Here is an example of the modified install handler.
def installed() {
if(parent) { installChild() } // This will handle all of the install functions when the child app is installed
else { installParent() } // This will handle all of the install functions when the parent app is installed
}
Question about this…
If parent is true, why install child, wouldn’t you install parent? Or is that saying if parent exists then you must be a child?
parent will only be true in a child app. That’s part of the cleverness in this workaround
I really appreciate the help…
I think I am almost there. How do I go about getting the app to realize setup is done? See how there is no “Done” link/button…
Also, I updated the code in github.
add the install: true
To accomplish that just add the install:true tag to the page like this
dynamicPage(name: "setNotificationPage", title: "Configure Notification Options", install: true, uninstall: true) {
Thanks. I’m in! Now I can convert the 3-4 apps I’ve written to be parent / child apps.
Hi Guys,
Sorry to reanimating an old topic but I have a very similar issue.
When I’m trying to use the Parent/Child app and I try to create a new child app I just have a spinning wheel on the screen. When the spinning wheel is spinning if I lock and unlock the iPhone a new child app get created and I can click on it and works.
The weird thing is if I remove the input from the child app it works just fine.
def childStartPage() {
dynamicPage(name: “childStartPage”, title: “Select your devices and settings”, install: true, uninstall: false) {
section(“Name”) {
label(title: “Assign a name”, required: false)
}
// Here is the problem if I have at least one input the app get stuck to add a childapp in the mobile app
// If I comment the lines bellow it work
section(“4 speed fan control:”){
input(“speedfan4”, “bool”, title: “Enable if using 4 speed fan:”, defaultValue: false, required: false)
}
}
}
The hybrid parent/child workaround broke a few months ago with the IOS app update. It continues to work fine on android. I had to split all my apps into parent and child recently because of this.
If u really want to keep the hybrid setup you can do the following:
When the spinning wheel occurs, hit the power button on your device to turn OFF the screen. Then reopen. You should now have a blank “child” app in your list. Click on it and configure as normal. The problem should not reoccur because it only seems to occur when initializing the very first child app.
Far from ideal and that’s why I swapped to the officially supported P/C setup.