Groovy runtime exception on runDaily. Complains about method parameters

(MrPresident) #1

I am writing a smartApp that schedules a light to turn on and then off again at a given time.
When I try to install the app in the IDE for testing, I get a groovy runtime exception.

groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method script1415065329498578984625#runDaily.
Cannot resolve which method to invoke for [null, class java.lang.String] due to overlapping prototypes between:
[class java.lang.String, class java.lang.Object]
[class java.util.Date, class java.lang.Object] @ line 99

The code I’m writing is below. Can someone try this and see if you get the same error? And perhaps explain why?
Thanks in advance,

    name: "foyerLampSunset",
    namespace: "mlupo",
    author: "michael lupo",
    description: "Turn the foyer lamp on 1.5 hours before sunset and leave on till 11:59pm.",
    category: "Safety & Security",
    iconUrl: "",
    iconX2Url: "",
    iconX3Url: "")

preferences {
	section ("At sunset...") {
		input "sunsetMode", "mode", title: "Change mode to?", required: false
		input "foyerOutlet", "capability.switch", title: "Turn on?", required: false, multiple: true
    section ("Sunset offset (optional)...") {
		input "sunsetOffsetValue", "text", title: "HH:MM", required: false
		input "sunsetOffsetDir", "enum", title: "Before or After", required: false, options: ["Before","After"]
    //section ("How long to leave the light on for? MINUTES (ie. 90)") {
	//	input name: "minutes", title: "Minutes?", type: "number", multiple: false
    //section("What time to turn the light off?") {
    //	input "time1", "time", title: "When?"
    section ("Zip code (optional, defaults to location coordinates)...") {
		input "zipCode", "text", required: false
	section( "Notifications" ) {
		input "sendPushMessage", "enum", title: "Send a push notification?", options: ["Yes", "No"], required: false
		input "phoneNumber", "phone", title: "Send a text message?", required: false

def installed() {

def updated() {
	//unschedule handled in astroCheck method

def initialize() {
	subscribe(location, "position", locationPositionChange)
	subscribe(location, "sunsetTime", sunriseSunsetTimeHandler)

def locationPositionChange(evt) {
	log.trace "locationChange()"

def sunriseSunsetTimeHandler(evt) {
	log.trace "sunriseSunsetTimeHandler()"

def astroCheck() {
    log.debug "sunsetOffset is: $sunsetOffset"
	def s = getSunriseAndSunset(zipCode: zipCode, sunriseOffset: sunriseOffset, sunsetOffset: sunsetOffset)
    def off = getSunriseAndSunset(zipCode: zipCode, sunriseOffset: sunriseOffset, sunsetOffset: sunsetOffset)
	def now = new Date()
	def sunsetTime = s.sunset
	log.debug "sunsetTime: $sunsetTime"
	if (state.sunsetTime != sunsetTime.time) {
		state.sunsetTime = sunsetTime.time

		if(sunsetTime.before(now)) {
		} "scheduling sunset handler for a sunset at: $sunsetTime"
		runDaily(sunsetOffSetTime, sunsetHandler)

def sunsetHandler() { "Executing sunset handler. Will turn off the outlet at 11:59pm."
	if (foyerOutlet) {

def changeMode(newMode) {
	if (newMode && location.mode != newMode) {
		if (location.modes?.find{ == newMode}) {
			send "${label} has changed the mode to '${newMode}'"
		else {
			send "${label} tried to change to undefined mode '${newMode}'"

private send(msg) {
	if ( sendPushMessage != "No" ) {
		log.debug( "sending push message" )
		sendPush( msg )

	if ( phoneNumber ) {
		log.debug( "sending text message" )
		sendSms( phoneNumber, msg )

	log.debug msg

private getLabel() {
	app.label ?: "SmartThings"

private getSunriseOffset() {
	log.debug "DEBUG: getting offset value"
	sunsetOffsetValue ? (sunsetOffsetDir == "Before" ? "-$sunsetOffsetValue" : sunsetOffsetValue) : null

def outletOff() {
    //log.debug "called outletsOff() and delaying turning off the outlet till ${time1}"
    log.debug "called outletsOff() and delaying turning off the outlet at 11:59pm"
    schedule("00 59 23 * * ?", scheduledTurnOff)
    //schedule(time1, scheduledTurnOff)

def scheduledTurnOff() {
	unschedule("scheduledTurnOff") // Temporary work-around to scheduling bug

(Kristopher Kubicki) #2

I just stumbled across this - and I have the same issue.

(Aaron) #3

Maybe try schedule()