Pages issue in simulator

When using pages or dynamic pages in preferences{ } the events are never fired, installed() is never called (the ‘install’ button never shows in the simulator, only ‘update’) in the simulator. Any idea on what’s going on???

Below is the simple code:

preferences {

	page(name:"pageTest", title: "Page test") {
    		section("Monitor water leaks in this location...") {
			input "water1", "capability.waterSensor", title: "Which sensor?"
		}
   }
}
    
def installed() {
	log.debug "Installed with settings: ${settings}"
	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(water1, "water", waterHandler)
}

def waterHandler(evt) {
	log.debug "waterHandler"
 
}

And the log generated:
9:50:50 PM: trace water from water1 was provided with waterHandler…creating subscription
9:50:50 PM: trace SQHB Demo is attempting to unsubscribe from all events
9:50:50 PM: debug Updated with settings: [water1:water1]
9:50:50 PM: trace water from water1 was provided with waterHandler…creating subscription
9:50:50 PM: trace SQHB Demo is attempting to unsubscribe from all events
9:50:50 PM: debug Updated with settings: [water1:water1]
9:50:50 PM: trace water from water1 was provided with waterHandler…creating subscription
9:50:50 PM: trace SQHB Demo is attempting to unsubscribe from all events
9:50:50 PM: debug Updated with settings: [water1:water1]
9:50:50 PM: trace water from water1 was provided with waterHandler…creating subscription
9:50:50 PM: trace SQHB Demo is attempting to unsubscribe from all events
9:50:50 PM: debug Updated with settings: [water1:water1]

installed() is never called, for some reasons updated () is called multiple times and waterHandler() is never triggered.

The app works fine by removing the page from the preference as below:
preferences {

	//page(name:"pageTest", title: "Page test") {
    		section("Monitor water leaks in this location...") {
			input "water1", "capability.waterSensor", title: "Which sensor?"
	//	}
   }
}
    
def installed() {
	log.debug "Installed with settings: ${settings}"
	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(water1, "water", waterHandler)
}

def waterHandler(evt) {
	log.debug "waterHandler"
 
}

Which generate the logs:
10:00:48 PM: debug waterHandler
10:00:41 PM: trace water from water1 was provided with waterHandler…creating subscription
10:00:41 PM: debug Installed with settings: [water1:water1]

@bruno

You are missing some key companents to the page tags. For instace the page needs to have a “install: true” tag in order to be able to install the app. There is also a “uninstall: true/false” tag that can specify whether or not a certain page has the ability to uninstall and app. Without the install tag specifically you won’t be able to isntall the app, the uninstall tag is more for control than anything, but if you don’t specify at the very least to have the last page be a uninstall and install page the app won’t be ablle to be unisntalled and it will not install.

This is a more straight forward code example from one of my apps.

preferences {
	page( name:"Sensor", title:"Use the following temperature sensor...", nextPage:"Cold", uninstall:true, install:false ) {
    	section("Sensor"){
			input "sensor", "capability.temperatureMeasurement", title: "Sensor", multiple:false
		}
    }   
    page( name:"Cold", title:"Cold", nextPage:"Hot", uninstall:true, install:false ) {
    	section("When the temperature falls below this tempurature set mode to..."){
			input "setLow", "decimal", title: "Low temp?"
            input "cold", "enum", title: "Mode?", metadata:[values:["auto", "heat", "cool", "off"]], required:false
		}
    }
    page( name:"Hot", title:"Hot", nextPage:"Neutral", uninstall:true, install:false ) {
    	section("When the temperature goes above this tempurature set mode to..."){
			input "setHigh", "decimal", title: "High temp?"
            input "hot", "enum", title: "Mode?", metadata:[values:["auto", "heat", "cool", "off"]], required:false
		}
    }    
    page( name:"Neutral", title:"Neutral", nextPage:"Thermostat", uninstall:true, install:false ) {
    	section("When temperature is between the previous temperatures, change mode to..."){
            input "neutral", "enum", title: "Mode?", metadata:[values:["auto", "heat", "cool", "off"]], required:false
		}    
    }
    page( name:"Thermostat", title:"Thermostat", nextPage:"Settings", uninstall:true, install:false ) {
    		section("Choose thermostat...") {
			input "thermostat", "capability.thermostat", multiple: true
		}
    }
    page( name:"Settings", title:"Settings", uninstall:false, install:true ) {
    	section( "Notifications" ) {
			input "sendPushMessage", "enum", title: "Send a push notification?", metadata:[values:["Yes","No"]], required:false
    	}
        section(title: "More options", hidden: hideOptionsSection(), hideable: true) {
			
			def timeLabel = timeIntervalLabel()

			input "days", "enum", title: "Only on certain days of the week", multiple: true, required: false,
				options: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

			input "modes", "mode", title: "Only when mode is", multiple: true, required: false
		}
    }    
}

This is a dynamic page setup from another of my apps the dynamic page finds and allows users to select a hello home phrase to run during certain triggers, i this case its a app that sets them based on the time of day and whether the house is occupied or not.

preferences {
  page(name: "selectPhrases")
  
  page( name:"Settings", title:"Settings", uninstall:true, install:true ) {
  	section("False alarm threshold (defaults to 10 min)") {
    	input "falseAlarmThreshold", "decimal", title: "Number of minutes", required: false
  	}

  	section("Zip code (for sunrise/sunset)") {
   		input "zip", "decimal", required: false
  	}

      section("Notifications") {
        input "sendPushMessage", "enum", title: "Send a push notification?", metadata:[values:["Yes","No"]], required:false
  	}
    section(title: "More options", hidden: hideOptionsSection(), hideable: true) {
			
			def timeLabel = timeIntervalLabel()

			href "timeIntervalInput", title: "Only during a certain time", description: timeLabel ?: "Tap to set", state: timeLabel ? "complete" : null

			input "days", "enum", title: "Only on certain days of the week", multiple: true, required: false,
				options: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]

			input "modes", "mode", title: "Only when mode is", multiple: true, required: false
		}
  }
}

def selectPhrases() {
	def configured = (settings.awayDay && settings.awayNight && settings.homeDay && settings.awayDay)
    dynamicPage(name: "selectPhrases", title: "Configure", nextPage:"Settings", uninstall: true) {		
		section("Who?") {
			input "people", "capability.presenceSensor", title: "People", required: true, multiple: true,  refreshAfterSelection:true
		}
        
		def phrases = location.helloHome?.getPhrases()*.label
		if (phrases) {
        	phrases.sort()
			section("Hello Home Actions") {
				log.trace phrases
				input "awayDay", "enum", title: "awayDay", required: true, options: phrases,  refreshAfterSelection:true
				input "awayNight", "enum", title: "awayNight", required: true, options: phrases,  refreshAfterSelection:true
                input "homeDay", "enum", title: "homeDay", required: true, options: phrases,  refreshAfterSelection:true
                input "homeNight", "enum", title: "homeNight", required: true, options: phrases,  refreshAfterSelection:true
			}
		}
    }
}

Hope this helps.

@tslagle13 Thanks for helping. You’re right about the “install” tag, it was somehow missing from my sample code. The issue is that even using it doesn’t solve the problem. I get exactly the same behavior with “install:true” or “install:false” or without “install”. Really confusing and frustrating…

If you copy and paste my code does it work? Maybe its some formatting error that you have within your code. could be as simple as a missing comma or something. If my code wors then you can rule out smartthings as the culprit and know that your code needs to be looked at. The preference pages above definitely work so if they don’t work for you it might be something wrong with the IDE.

I am also having this same problem in the simulator. As soon as I add a page to the preference the events no longer fire.
This works fine…

preferences {
          section("controller") {
            input "buttonDevice", "capability.button", title: "Button", multiple: false, required: true
          }
         section("sonos") {
           input "sonos", "capability.musicPlayer", title: "On this Sonos player", multiple:false, required: true
         }
}

This does not work at all. The events from the remote never fire.

preferences {
        page(name:"choose devices",install:true,uninstall:true){
          section("controller") {
            input "buttonDevice", "capability.button", title: "Button", multiple: false, required: true
          }
         section("sonos") {
           input "sonos", "capability.musicPlayer", title: "On this Sonos player", multiple:false, required: true
         }
        }
}

I’ve had very similar problems.

The symptom I was observing seemed to be that with pages added to my app, I could not get the app to actually install - it would update (as though it had already been installed) but never actually install in the first place, which I think means that none of the eventHandlers and whatnot were getting registered. (However my preferences did seem to be getting stored.)

It worked properly on the phone app outside the simulator, so I worked around it by debugging “live”.

Yes I have had to switch to almost always doing live debugging.

FWIW, I’ve had exactly the same issue. I’m glad to know I’m not going crazy.

For those of you who have worked around this problem by debugging “live”, do you get logs at https://graph.api.smartthings.com/ide/logs or do you use something like sendNotificationEvent?

When debugging “live”, can you hit “Save” in the IDE, then visit your app on your phone and just click “Update” or are more steps required?

1 Like