SmartApp Error - "MissingMethodException: No signature of method:"


(Owen Murphy) #1

I’m trying to write a simple datalogging app, but I keep getting an error when my event handler is called, and I’m not sure what it means. The event handler is set to fire off every minute using the “RunEvery1Minute” function. Everything in the event handler function seems to execute properly, but every time it runs, I get an error about 10-15 seconds afterwards.

Here is my code:
preferences {
section(“Select a Temperature Sensor…”){
input “LivingRoomSensor”, “capability.temperatureMeasurement”, title: “Living Room Temperature Sensor”
}
}

def installed() {
	log.debug "Installed with settings: ${settings}"

	initialize()
}

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

	unsubscribe()
	initialize()
}

def initialize() {
	log.debug "initalize"
    runEvery1Minute(temperatureHandler)
	log.debug "runEvery1Minute executed"
	subscribe(LivingRoomSensor, "temperature", temperatureHandler)
    log.debug "subscribe completed"
}

def temperatureHandler(evt)
{
	log.debug "temperatureHandler called"
    log.debug "LivingRoomSensor is " + LivingRoomSensor.currentTemperature.toString()
}

This is what I get in the log:
6110f792-56f7-4834-9ebf-356c9b34decc 9:07:19 PM: debug LivingRoomSensor is 68

[6110f792-56f7-4834-9ebf-356c9b34decc](https://graph-na04-useast2.api.smartthings.com/ide/app/editor/6ad8938f-57ed-4ff4-8bea-98df84cf98f6#6110f792-56f7-4834-9ebf-356c9b34decc) 9:07:19 PM: debug temperatureHandler called

[6110f792-56f7-4834-9ebf-356c9b34decc](https://graph-na04-useast2.api.smartthings.com/ide/app/editor/6ad8938f-57ed-4ff4-8bea-98df84cf98f6#6110f792-56f7-4834-9ebf-356c9b34decc) 9:06:38 PM: error groovy.lang.MissingMethodException: No signature of method: script_app_8ff16631f81a982c49b6025f730c6150260d4570a3a75beb19bab18d2baf2bdc.null() is applicable for argument types: () values: []
Possible solutions: url(), url(java.util.Map), run(), dump(), now(), run()

[6110f792-56f7-4834-9ebf-356c9b34decc](https://graph-na04-useast2.api.smartthings.com/ide/app/editor/6ad8938f-57ed-4ff4-8bea-98df84cf98f6#6110f792-56f7-4834-9ebf-356c9b34decc) 9:06:22 PM: debug LivingRoomSensor is 68

[6110f792-56f7-4834-9ebf-356c9b34decc](https://graph-na04-useast2.api.smartthings.com/ide/app/editor/6ad8938f-57ed-4ff4-8bea-98df84cf98f6#6110f792-56f7-4834-9ebf-356c9b34decc) 9:06:22 PM: debug temperatureHandler called

[6110f792-56f7-4834-9ebf-356c9b34decc](https://graph-na04-useast2.api.smartthings.com/ide/app/editor/6ad8938f-57ed-4ff4-8bea-98df84cf98f6#6110f792-56f7-4834-9ebf-356c9b34decc) 9:05:39 PM: error groovy.lang.MissingMethodException: No signature of method: script_app_8ff16631f81a982c49b6025f730c6150260d4570a3a75beb19bab18d2baf2bdc.null() is applicable for argument types: () values: []
Possible solutions: url(), url(java.util.Map), run(), dump(), now(), run()

Does anyone have any ideas what this could be? I have programming experience with C and a tiny bit of C++ and C#, but this is the first time I’ve used Groovy, so it’s probably something obvious. I’m still trying to wrap my head around the way things are programmed.


(Steve White) #2

First a general question… What are you trying to accomplish by both scheduling readings and using an event handler? By subscribing to the e ents from the temperature sensor, the handler will be called anytime there’s a change in reading. Scheduling the logger to read every minute is going to provide a lot of redundant and duplicate data.

You’re better off eliminating the scheduled function calls and only calling the logger when the temperature event is fired.

As far as your errors you’re trying to call an event handler with event object as the argument. The scheduler does not pass an event object, so you’ve got an argument type mismatch. Again, eliminating the scheduled event will fix this.


(Tony Fleisher) #3

If you want to pass parameter into a scheduled method, the parameter needs to be defined.
See the command reference and signature details here:
https://docs.smartthings.com/en/latest/ref-docs/smartapp-ref.html#smartapp-run-every-1-minute


(Owen Murphy) #4

I’m scheduling readings at a fixed interval, even though the sensor will trigger an event when the temp changes, because I want to create a framework to add other sensors that may or may not trigger an event when the recorded value changes (or the record value changes too much - like a temp sensor with a few decimal places of resolution). I want to be able to log at a fixed interval rather than asynchronously tied to external events.

It turned out the error was caused by the line:
log.debug "LivingRoomSensor is " + LivingRoomSensor.currentTemperature.toString()

When I commented it out, I no longer see the error. I’m still not sure why… Maybe because it was an order of operations error and the program was trying to add “LivingRoomSensor.currentTemperature.toString()” to “log.debug…”?


#5

Me neither …

As others have mentioned it would appear that the log was showing an error every minute as the scheduler ran because it is looking for temperatureHandler() but only finding temperatureHandler(evt) which is declared to expect an argument.

It would also appear that the temperature sensor is producing a temperature event every minute anyway and that was producing the successful logging.

Have you changed anything else?


(Owen Murphy) #6

Nope. The only thing I changed was commenting out that line.

In fact, I just changed the code to remove the “evt” argument from the “temperatureHandler()” function and I end up getting the following error:

[b26ceeed-40f0-40ec-81a1-a9137d7f8d0b](https://graph-na04-useast2.api.smartthings.com/ide/app/editor/6ad8938f-57ed-4ff4-8bea-98df84cf98f6#b26ceeed-40f0-40ec-81a1-a9137d7f8d0b) 6:51:15 PM: error groovy.lang.MissingMethodException: No signature of method: script_app_2cd9dbc78fc00242ba45f2c06ce31e40e962496225dabecff770495a02defa6f.temperatureHandler() is applicable for argument types: (physicalgraph.app.EventWrapper) values: [physicalgraph.app.EventWrapper@78fb9488]
Possible solutions: temperatureHandler()

[b26ceeed-40f0-40ec-81a1-a9137d7f8d0b](https://graph-na04-useast2.api.smartthings.com/ide/app/editor/6ad8938f-57ed-4ff4-8bea-98df84cf98f6#b26ceeed-40f0-40ec-81a1-a9137d7f8d0b) 6:51:12 PM: error groovy.lang.MissingMethodException: No signature of method: script_app_2cd9dbc78fc00242ba45f2c06ce31e40e962496225dabecff770495a02defa6f.temperatureHandler() is applicable for argument types: (physicalgraph.app.EventWrapper) values: [physicalgraph.app.EventWrapper@4c37e3a]
Possible solutions: temperatureHandler()

I’m not too concerned at this point since I have working code. I’m sure as I dig into writing code for SmartThings more, I’ll understand what went wrong a little better, but right now, I’m OK with it as it is. Thanks for the replies.


#7

Yes, that’s the subscribed events giving the error this time, with the scheduled run working. You either need both temperatureHandler(evt) and temperatureHandler() (method overloading allows this and one can call the other), or you can add an argument when scheduling, or you can probably default the value in the method parameter.


(Mark C) #8

how you you subscribe to a specifice deviece? what name do you use?
i want to subscribe to event from this device
image


#9

https://docs.smartthings.com/en/latest/smartapp-developers-guide/simple-event-handler-smartapps.html might help.


(Mark C) #10

thanks in the example what is “theSwitch” refering to?
subscribe(theSwitch, “switch.on”, switchOnHandler)

is this limited to APP’s not DH’s?


#11
preferences {
    section {
        input "theSwitch", "capability.switch"
    }
}

There it is. So in this example when you install/update the SmartApp it will prompt you with a list of your devices with capability ‘Switch’ and you choose which one you want. That then goes into the variable name specified (‘theSwitch’).

If you go back to the original post you will see that SmartApp had:

preferences {
section("Select a Temperature Sensor…"){
input "LivingRoomSensor", "capability.temperatureMeasurement", title: "Living Room Temperature Sensor"
}
}

In that example the variable name used in the subscribe() is LivingRoomSensor.

It is for SmartApps only.