Problem with button subscription

I’ve a smartapp that handles switches, sirens, contact sensors, … working without problems. However, when I try to add a push button, in simulation mode, the button callback method is never called.

I’ve tried with a very small test smartapp:

definition(
    name: "Test",
    namespace: "myhome",
    author: "",
    description: "test",
    category: "My Apps",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png" )


preferences {
    section("Main door") {
		input ( name: "buttonOff", 
				type: "capability.button",
				title: "Button Alarm Off",
				required: true )
    }
  }

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

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

def initialize() {
    log.debug "initialize"
    subscribe(buttonOff, "button.pushed", onButtonOff)
}

def onButtonOff(evt) {
  log.debug "onButtonOff: evt=$evt"
}

with same result. When the simulation starts, a virtual button appears, with five options on it: button 1 pushed, button 1 held, … . However, none of them seems to trigger the method “onButtonOff” to write the log message.

Any hint?

Addendum:

If I’ve the “live logging” opened in another window, following message appears when the option “button1 pushed” of the virtual button is clicked:

 b6770c4e-57e2-4139-b39c-f1b76b2364c3 5:00:05 PM: error groovy.lang.MissingMethodException: No signature of method: script_dth_436b0865_5bbd_4160_89b0_b34cd798e940_ver_6_6.zwaveEvent() is applicable for argument types: (physicalgraph.zwave.commands.basicv1.BasicSet) values: [BasicSet(value: 21)]
Possible solutions: createEvent(java.util.Map) 

Thanks a lot.

On your ‘subscribe’ line try changing the “button.pushed” to “button”

Hi,

Thanks for your interest in this issue.

Done with:

 subscribe(buttonOff, "button", onButtonOff)

but same result, no trigger of callback.

Also tested:

 subscribe(buttonOff, "button1", onButtonOff)

no luck.

Is that error coming from your smart app or the device handler?

1 Like

Hi Eric,

Thanks for your help.

Error message in the “live logging” appears under the tab “buttonOff” of the live logging, not in the “Test” tab, thus, I suppose it is coming from the device handler.

In the test location I’ve no custom device handlers.

Then the problem is not with the smartapp

Yes, it could be, but it is a very simple example app and using the standard virtual button, (not using a custom one), I’ve no idea what I’m doing wrong.

It will be very, very useful if someone loads this app in his own test environment and checks if the error happens.

What virtual button are you using? Your SmartApp works fine for me with the following button DH and the out of the box ST “Simulated Button”.

As you know, when simulation is started, the IDE allows to select the device (for each input) to be used. One of them is the virtual one, the other ones are the physical ones that are connected to the hub (if any).

I’m testing in a pure virtual location, no physical devices, the button is the virtual one that the IDE allows. In this case, the callback is never called and the error message appears.

When testing in a real location and with a physical button, the app works as expected, the callback is called. Could be an error in the official IDE simulator ?

Yes.

:warning: Never trust the Simulator!!!

What he said.

2 Likes

ok, understood, thanks a lot.

Is this software element available in any public repository ? ( in some places it is said that smartthings is FOS, but the only code I’ve found is for some smartapps and handlers ).

Moreover, If someone confirms the issue, we could raise an issue to Samsung ( how ? )

  1. A lot (but not all) shared SmartThings Code (including Virtual Switch Device Types…) are in: https://github.com/SmartThingsCommunity/SmartThingsPublic

  2. You can contact Support@SmartThings.com to raise issues; but be forewarned: You very likely will not get assistance with development problems (IDE, etc.).

1 Like

Thanks for the links.

Could be an error in the capabilty code (see here) ?

The “parse” method is calling “zwaveEvent”, but this one is not defined in the code.

If we compare with other capabilities, most of them doesn’t use “parse” at all, and the ones that uses it defines a lot of “zwaveEvent” methods (see capability zwave-motion-sensor by example)

zwaveEvent is built into the platform, but is not required for parse() to work. A DTH can receive ZigBee messages, as well as IP (LAN) or cloud-cloud API messages from a service manager.

I’m sorry… But I’ve lost track of what is your question or issue?

If the issue is that the Simulator appears to be malfunctioning, then it’s definitely not worth any time to debug it. NEVER trust or even bother with the simulator!

Just publish and install / instantiate your SmartApp, real or virtual Device(s), test using the mobile App while viewing the Live Logging tab in the IDE.

1 Like

Hi,

The original question is “why this app doesn’t works in the simulator?”.

After the received answers and collected info, problem seems related to the device handler of the simulator button, that seems implemented in the capability definition, thus, next question is “there are an error in the implementation of the simulation of the button or its is something specific of my environment?”.

Finally, as this part is open-source, I can not agree with the statement “it’s definitely not worth any time to debug it”, issue can and must be fixed and error reported to their maintainers. Of course, this is a voluntary activity for person who want collaborate in the project.

Kind regards.

The simulator is not open source.

The code of the “virtual buttons” you can create in the simulator is not the same as “simulated buttons” you can generate by manually creating instances from source code. This latter method is much more powerful as you can add custom debugging statements anywhere in the DTH (as well as in your SmartApp).

Anyhow, if you don’t care for my advice, there’s nothing I can do:

  • Never trust the simulator. and
  • The IDE is never going to be fixed.
2 Likes

It is probably very frustrating to you, @DiasExtranyos, but what @tgauchat says is borne out by years of experience with the SmartThings platform. Feel free to report issues about the simulator and/or IDE to Support — just don’t expect anything to be fixed! You can search the forum to find many other threads expressing this same frustration!

In the meantime, perhaps you will find out what works for you and how to work around the shortcomings of the development platform. There are a lot of powerful things that can be done here…

1 Like