I am trying to build a virtual “push button” switch for Alexa. Why is the code below not sending the button.pushed event when the switch.on() function is called? Is there some relation between what events the system will allow and the UI tile definition that I don’t understand?
I see my log message from the on() function and the device behaves as expected, with the exception of not sending the pushed event.
metadata {
definition (name: "Virtual push button for Alexa", namespace: "qqq", author: "qqq") {
capability "Actuator"
capability "Switch"
capability "Button"
capability "Sensor"
}
// simulator metadata
simulator
{
}
// UI tile definitions
tiles {
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
state "on", label: 'On', action: "switch.on", backgroundColor: "#53a7c0", nextState: "nc"
state "off", label: 'Off', action: "switch.off", backgroundColor: "#222222", nextState: "nc"
state "nc", label: 'Push', action: "switch.on", backgroundColor: "#ffffff"
}
main "switch"
details "switch"
}
}
def parse(String description)
{
}
def on()
{
log.debug "Pushing $device.displayName"
sendEvent(name: “button”, value: “pushed”, descriptionText: “$device.displayName was pushed”)
sendEvent(name: “switch”, value: “on”, isStateChange: true, display: false)
sendEvent(name: “switch”, value: “nc”, isStateChange: true, display: false)
}
def off()
{
sendEvent(name: “switch”, value: “off”, isStateChange: true, display: false)
sendEvent(name: “switch”, value: “nc”, isStateChange: true, display: false)
}