Simulator can't run with multiple enum input


(Ethan Ferrell) #1

I seem to be having a problem with the simulator when I have a enum type that allows multiple selections. If I change the input type to not allow multiple selections, it runs fine.

For example, here’s my code:

/**
 *  Alarm Clock
 */
preferences {
    section("Turn these switches on for alarm") {
	input("switches", "capability.switch", multiple: true, required: true)
    }
    section("
	input("time", "time", multiple: false, required: true)
	input("days", "enum", multiple: true, required: true, metadata:[values:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]])
    }
}

def installed() {
	log.debug("Installed app")
	initialize()
}

def updated() {
	log.debug("Updated app")
	unschedule()
	initialize()
}

def initialize() {
	
	log.debug("days=${days}")

	def calendar = Calendar.getInstance()
	calendar.setTimeZone(TimeZone.getTimeZone("GMT-5"))
	def today = calendar.get(Calendar.DAY_OF_WEEK)
	log.debug("today=${today}")

	def todayValid = null
	switch (today) {
		case Calendar.MONDAY:
			todayValid = days.find{it.equals("Monday")}
			log.debug("today is Monday")
			break
		case Calendar.TUESDAY:
			todayValid = days.find{it.equals("Tuesday")}
			log.debug("today is Tuesday")
			break
		case Calendar.WEDNESDAY:
			todayValid = days.find{it.equals("Wednesday")}
			log.debug("today is Wednesday")
			break
		case Calendar.THURSDAY:
			todayValid = days.find{it.equals("Thursday")}
			log.debug("today is Thursday")
			break
		case Calendar.FRIDAY:
			todayValid = days.find{it.equals("Friday")}
			log.debug("today is Friday")
			break
		case Calendar.SATURDAY:
			todayValid = days.find{it.equals("Saturday")}
			log.debug("today is Saturday")
			break
		case Calendar.SUNDAY:
			todayValid = days.find{it.equals("Sunday")}
			log.debug("today is Sunday")
			break
	}
    
	log.debug("valid=${todayValid}")
	
	//schedule(time, wakeupAlarm)
}

def wakeupAlarm() {
	switches?.on()
}

Not a complete app, but I’m still testing stuff out in the initialize section. If anyone has any other improvements feel free to mention them.


Enum input type doesn't support multiple
(Ethan Ferrell) #2

Cant seem to edit my post. Had a copy and paste fail…

/**
 *  Alarm Clock
 *
 *  Author: ethan.ferrell@gmail.com
 *  Date: 2013-08-31
 */
preferences {
    section("Turn these switches on for alarm") {
    	input("switches", "capability.switch", multiple: true, required: true)
    }
    section("Schedule") {
    	input("time", "time", multiple: false, required: true)
        input("days", "enum", multiple: false, required: true, metadata:[values:["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]])
    }
}

def installed() {
	log.debug("Installed app")
	initialize()
}

def updated() {
	log.debug("Updated app")
    unschedule()
	initialize()
}

def initialize() {
	
	log.debug("days=${days}")

	def calendar = Calendar.getInstance()
	calendar.setTimeZone(TimeZone.getTimeZone("GMT-5"))
	def today = calendar.get(Calendar.DAY_OF_WEEK)
	log.debug("today=${today}")

	def todayValid = null
	switch (today) {
		case Calendar.MONDAY:
			todayValid = days.find{it.equals("Monday")}
			log.debug("today is Monday")
			break
		case Calendar.TUESDAY:
			todayValid = days.find{it.equals("Tuesday")}
			log.debug("today is Tuesday")
			break
		case Calendar.WEDNESDAY:
			todayValid = days.find{it.equals("Wednesday")}
			log.debug("today is Wednesday")
			break
		case Calendar.THURSDAY:
			todayValid = days.find{it.equals("Thursday")}
			log.debug("today is Thursday")
			break
		case Calendar.FRIDAY:
			todayValid = days.find{it.equals("Friday")}
			log.debug("today is Friday")
			break
		case Calendar.SATURDAY:
			todayValid = days.find{it.equals("Saturday")}
			log.debug("today is Saturday")
			break
		case Calendar.SUNDAY:
			todayValid = days.find{it.equals("Sunday")}
			log.debug("today is Sunday")
			break
	}
    
	log.debug("valid=${todayValid}")
	
	//schedule(time, wakeupAlarm)
}

def wakeupAlarm() {
	switches?.on()
}

(Curtmcgirt) #3

did you ever figure this out?


(Curtmcgirt) #4

actually, let me rephrase:
yours is the only attempt at defining scheduling behavior for days of the week that I’ve been able to find. I can’t find any in “browse smartapps” on the IDE. all the “on a schedule” smartapps do the same thing at the same time 7 days a week.

I’m trying to write one myself, and I’m putting a

def calendar = Calendar.getinstance()

in “def initialize,” but when I try to call $calendar later, I’m getting a null value.


(Curtmcgirt) #5

figured out my problem, and successfully modified a clone of the “scheduled mode change” smartapp to only run on Friday.

as for your problem, the code from your second post worked in the simulator for me even with multiple set to true. are you getting an error? at what point?


(Ethan Ferrell) #6

Hmm, it does seem to work now. I wonder if there was a problem that was fixed from last time I tried.


(Juhani) #7

Sorry for the thread necro, but I still have the same problem with simulator crashing with multiple enum.

    section("And the weather is..."){
        input"wumonitor", "enum", title: "Weather Conditions...", multiple: true,
            metadata:[
            	values:[
                	"clear",
                    "cloud",
                    "drizzle",
                    "fog",
                    "hail",
                    "mist",
                    "overcast",
                    "rain",
                    "snow",
                    "thunderstorm"
                ]
            ]
grails.validation.ValidationException: Validation Error(s) occurred during save(): - Field error in object 'physicalgraph.app.InstalledSmartApp' on field 'data': rejected value [[Weather-Aware Closet - wucity = "FI/Helsinki", Weather-Aware Closet - contact = "b34c285d-e6a4-4433-864e-bf0f29affd72", Weather-Aware Closet - wumonitor = ""]]; ... default message [{0} does not pass custom validation]

Switching to multiple: false allows me to test things.


(Ben Edwards) #8

We are going to be fixing this bug with an upcoming release (next week). For now you still can run this app on your mobile device as this bug is restricted to the simulator.