OnoffCmd Ability

Anyway to get this function to work? Almost like a momentary switch

def on() {
onOffCmd(device.deviceNetworkId, 255)
cmds >> “delay:1000”
cmds >> onOffCmd(device.deviceNetworkId, 0)


def off() {
onOffCmd(device.deviceNetworkId, 0)


if your goal is to have your switch on for x secs, in your on(), send the on command to your device and arm a timer that calls the off event upon elapsing.

See https://docs.smartthings.com/en/latest/smartapp-developers-guide/scheduling.html?highlight=schedule