runIn command causing a Java exception


#1

I am trying to use the runIn command to create a "heartbeat" function. My code is:

// parse events into attributes
def parse(String description) {
// will run "watchdogAlarm" in 310 seconds, gets reset if command is run within 310 sec
runIn(310, watchdogAlarm, overwrite: true) 
log.debug "Parsing '${description}'"

the logs show an error:

2019-01-26 05:02:32.428 pm errorgroovy.lang.MissingMethodException: No signature of method: dev1548539168694219342782.runIn() is applicable for argument types: (java.util.LinkedHashMap, java.lang.Integer, java.lang.String) values: [[overwrite:true], 310, watchdogAlarm]

I know I don't need the "overwrite = true" but I included it for my better understanding of the syntax.

Its hard to read but runIn is all lower case except for the "I" in "in"

I've looked at ST documentation and can't see what I'm doing wrong.

My only thought is that is cannot be in the above locateion in the parse function, but I'm not sure where I else would put it.

Any thoughts would be appreciated.

Thanks
John


#2

runIn(310, watchdogAlarm, [overwrite: true])

You don't need the[overwrite: true], as that is the default. You only need to include it when you want [overwrite: false]. Overwrite true means that only one such runIn can be pending at one time. Any new one would overwrite any previous timer.


#3

Thanks.... so that was the issue.

I'm not s software guy but I don't recall ever seeing a command where defining the default condition caused an error.
Is this a Java / Groovy thing?

John


#4

You didn't define the default condition. You omitted the brackets that must surround the third parameter to runIn(). That parameter is a map, and you didn't have a map.

You had:

runIn(310, watchdogAlarm, overwrite: true)

Should be:

runIn(310, watchdogAlarm, [overwrite: true])


#5

I understand.... thank you :slight_smile:

I incorrectly assumed the brackets were an indication of the "optional" parameter.

JOhn


#6

I'm having a similar problem. I have a command which is returning a variable. This is how i have the command defined:

command "delayedOff", ["number"]

Then I have the function delayedOff defined as follows:

def delayedOff(delay){
	on()
    if (logEnable) log.debug "Turning off in"+delay+"seconds."	
	runIn(delay, off, )
}

No matter what I define the delayedOff to return it gives me an error. I've tried string, number, integer. It keeps giving me a no signature method error. I have looked high and low and I cannot find an answer to this anywhere. PLEASE HELP before I throw my keyboard out a window!


#7

get rid of the comma after off. Should be runIn(delay, off)


#9

Nope. Doesn't work.

def delayedOff(delay){
	on()
	runIn(delay, off)
}

Returns:

dev:16972019-02-03 05:06:42.949 pm errorgroovy.lang.MissingMethodException: No signature of method: dev1549231593798278521127.runIn() is applicable for argument types: (java.lang.String, java.lang.String) values: [10, off] Possible solutions: run(), run(), run(java.io.File, [Ljava.lang.String;), println(), on(), println() on line 49 (delayedOff)


#10

what are you trying to do?

what is off? the command is to run something in xx seconds. So you should be trying to run off()

The on() isn't going to do anything either unless you defined something as on

ex. def on()

... what is being turned on?


#11

Try adding
myDelay=delay.toInteger()
runIn(myDelay,off)


#12

THANK YOU!!!!! This is what I get for not being a coder. LMAO
I tried setting the command to return an integer with:

	command "delayedOff", ["integer"]

But I guess that wasn't enough. UGH!

What I'm trying to do is to finally move the last of my webCoRE pistons back over to ST cloud. I have it set up so that I can engage override switches for a specific amount of time via Google Home. So, I can say, "Turn on office override for 1 hour" and it will turn the office override on for 1 hour and then turn it off. I was trying to see if that would be easier to do with the driver than via the piston. Since the function requires the internet, i'm not worried about the internet being down because I wouldn't be able to use it anyway. But if the internet goes down in between I still want the switch to turn off after the hour. Rather than call it from ST I was trying to do it in the driver by passing the value through the Maker API.

I have been trying to figure this out for at least 2 hours. OMG...you don't know how much I appreciate the help. :+1:


#13

Not a problem. As an Fyi, I remember @mike.maxwell mentioning that the parameter for commands are always Strings. That's why it had to be converted to an Integer. The ["number"] is really just a label for the input box, so you could change it to ["delay"] and it would now show the word "delay" next to the input box.

I couldn't find the post but it's out there somewhere.

EDIT: see a few posts down :point_up_2: is not completely accurate.


#14

Well then....don't I feel like a complete moron. #facepalm :hot_face:
But now I've got it. :partying_face: Thanks again!!


#15

Well....while hunting down the post (which may or may not exist :man_shrugging:) I came across this one. Forgot about this. It actually details the command documentation...where in fact you can pass a numerical value as well as other options. Check it out