SmartThings Outlet Momentary Delay On Off Cycle Switching Solved

communitydevices

#1

It took me a while to figure this out but I needed to have the ST Outlet Wall Socket Thing do a momentary on then off again.
Finally solved the issue and want to share the solution with others who would like to get it working.
My purpose is to connect a transformer to a relay that is activated for 2 seconds then turned off again. Opening a Garage door - poor mans style. All safety is handled by the door motor and built in sensors - so all good.
The 1000 in the code is the delay in seconds till next command - so half a second is 500 and 2 seconds is 2000.
You could even make the outlet flash a few times using this method if needed.

Edit/Copy the “SmartPower Outlet” device handler and replace as shown below.

def off() {
zigbee.off()
}

def on() {
delayBetween([
zigbee.on(),
zigbee.off()
], 1000)
}

def refresh() {
sendEvent(name: “heartbeat”, value: “alive”, displayed:false)
zigbee.onOffRefresh() + zigbee.refreshData(“0x0B04”, “0x050B”)
}

Might seem simple when you see the code.
Anyway hope it helps someone :slight_smile: