Using Pages in setup... program installs, doesn't work

So I’m trying to rework my Goodnight Ubi app and make it work with any TTS devices. I’m also trying to make the app more user friendly and feel smoother when installing. I’ve never used pages before when creating an app, so I’m trying to learn the process.

I’ve got my app coded up and I have all the pages set. I publish it, and then install it on my phone. The installation works fine. But… the program doesn’t.

To test and make sure the logic of my program is correct I reworked the preferences section all as “sections()” instead of pages and it works, so I’m confident in the logic part of my app. I fear I’m missing something in the pages setup. Any ideas?

Here’s what I got for my prefs plus the pages:

preferences {
	page(name: "pageMain")
	page(name: "pageMisc")
    page(name: "pageDoorWin")
    page(name: "pageLightsOn")
    page(name: "pageLightsOff")
    page(name: "pageRoutine")
}

def pageMain() {
	dynamicPage(name: "pageMain", uninstall: true) {
	    section() {
        	paragraph "Goodnight SmartHome uses a virtual button to know when to run.  You will name that later on."
            paragraph "To run the app, turn that device on either by manually tapping it in the mobile app, "
        }    
        section("Setup Menu") {
            href "pageMisc", title:"Setup Button and Speaker", description:"Tap to open"
            href "pageDoorWin", title:"Select Doors and Windows to check", description:"Tap to open"
            href "pageLightsOn", title:"Optional: Select which Lights to turn on", description:"Tap to open"
            href "pageLightsOff", title:"Optional: Select which Light to turn off", description:"Tap to open"
            href "pageRoutine", title:"Optional: Choose a Routine to Run", description:"Tap to open"
        }

	    section("Options") {
            label title:"Assign a name", required:false
        }
	}
}

def pageMisc() {
    dynamicPage(name: "pageMisc", uninstall: true) {
		section("Select Virtual Device here") {
        	input "trigger", "capability.switch", title: "Which?", required: true
        }
        section() {
        	paragraph "Next we'll need to know what device you're going to be using as your speaker."      
        }
        section("Text-to-Speach Device") {
        	input "TTspeaker", "capability.speechSynthesis", title: "Select your TTS Speaker", required: true
	    }
	}
}

def pageLightsOn() {
    dynamicPage(name: "pageLightsOn", uninstall: true) {
    	section() {
        	paragraph "Select any lights you want to turn on when this app runs."
            paragraph "For example maybe a hallway light leading to a bedroom."
            paragraph "If you want these lights to turn off automatically later, be sure to include them in the next section that turns lights off."
        }    
	    section() {	
        	input "onSwitches", "capability.switch", title: "Which lights?", multiple: true, required: false
		}
	}
}

def pageLightsOff() {
    dynamicPage(name: "pageLightsOff", uninstall: true) {
    	section() {
        	paragraph "Select any lights you want to turn off when this app runs."
            paragraph "You will also need to indicate how many minutes after the app starts that these lights should turn off."
        }    
		section() {
			input "theSwitches", "capability.switch", title: "Which lights?", multiple: true, required: false
            input "minutes", "number", title: "After how many minutes?", required: false
		}
	}
}

def pageDoorWin() {
	dynamicPage(name: "pageDoorWin", uninstall: true) {
		section(){
        	paragraph "Select all the windows and doors that you want to monitor."
            paragraph "SmartThings will read off the names of any selected sensor that is left open when this app runs."
        }
        section(){
			input "doors", "capability.contactSensor", title: "Which doors/windows?", multiple: true
        }
	}
}

def pageRoutine() {    
    dynamicPage(name: "pageRoutine", title: "First, select your phrases", uninstall: true) {        
        def phrases = location.helloHome?.getPhrases()*.label
    	section() {
        	paragraph	"If you'd like to select a Routine to run, enter it here."
        }
        section("Select HelloHome Phrase") {
				input "phrase2", "enum", title: "Phrase", required: false, options: phrases
		}
        section("When would you like to run the routine??") {
        	input "minutes2", "number", title: "After how many minutes?", required: false
        }
	}
}

def installed() {
	log.debug "Installed with settings: ${settings}"
    log.debug "trigger is ${trigger}"
    log.debug "Do you see me?"
	initialize()
}

Chris,

After you install it go look at it’s state in the IDE. My Locations, List SmartApps, etc. There you can see all of the inputs, and you can check to see if they are correct.

Does your app have a single main page when you install it? That’s what it looks like from your code above. If you have multiple sequential pages during install, you would need to put that in the dynamic page definition, using nextPage: xxx.

Once again, you have to use the debugging tools available, including seeing the smartapp state as above, and using log.debug messages to see where the app is at as it installs, or runs.

To add to what bruce said,

I don’t think I saw the “install” flag on any of the pages. The page you want to complete the install should have a “install: true” flag on it.

2 Likes

Yup @slagle, I actually figure that out just a little bit ago from a previous thread asking a similar question that I didn’t before when I searched. Once I added that Install: true to the first main page, then it installs!

@bravenel the problem I ran into was that it wasn’t installing. The debug’s didn’t help because they never showed up because the program didn’t install, so in this isolated case, debug.log wouldn’t help.

3 Likes