I’m writing my very first smart app and struggling with some of the basics. I’ve successfully subscribed to temperature events and have working code based on these events, but now I’ve run into a problem with Button events. I’ve stripped everything away down to the basic code and I still can’t get my code to work.
The Use Case here is that in my Smart App, I define an Iris Smart Button in the configuration screen and then when that button is pressed, I log some information to debug. Super simple, but I cannot make it work. Clearly I’m doing something wrong with the event handler.
Any help would be greatly appreciated!
/**
- Test Code
*/
definition(
name: “Test Code”,
namespace: “wjarrettc”,
author: “W. Jarrett Campbell”,
description: “test”,
category: “Convenience”,
iconUrl: “http://cdn.device-icons.smartthings.com/Appliances/appliances1-icn@2x.png”,
iconX2Url: “http://cdn.device-icons.smartthings.com/Appliances/appliances1-icn@2x.png”
)
preferences {
section("Choose the button... "){ input "buttonDevice", "capability.button", title: "Test Button", multiple: false, required: true
}
}
def installed()
{
initialize()
}
def updated()
{
unsubscribe()
initialize()
}
def initialize()
{
subscribe(buttonDevice, "button", buttonEvent) log.debug "subscribed to BUTTON"
}
def buttonEvent(evt)
{
log.debug “$evt.device.displayName reported event $evt.stringValue”
}