State change on button press

Hey folks, I have a quick question I haven’t been able to answer with the Google. When creating an automation in the new Smartthings app I only have the option to set the state of a Smartthings Outlet to specifically On or Off when a button is pressed. Is there any way to set an automation that will perform a state change instead? That is, when the button is pressed the power state of the outlet will switch to the opposite state; if it is on the button press will turn it off, and vice versa.

I’m hoping this is a solved problem already, if not, any advice on how to create a custom script or handler will be appreciated, I’ll go ahead and scribble down some code to achieve it.

(The Classic App is still a bit more flexible and this could be done in a Device Type Handler even. … Or I bet Smart Lighting could be coaxed into doing it!!!)

Custom scripts are called “SmartApps” and I think most work in either App. This simple case is a rather trivial SmartApp, but you still need someone with Groovy skills to program it… probably takes 1/2 hour plus testing.

Or use webCoRE (a sophisticated “Rules Engine” with a simpler rule description language, instead of Groovy). It can easily check a condition: If Virtual Button X is pressed, check state of Switch Y, if on turn off, etc.

Google webCoRE and you’ll find all it’s details (it has own website for installation).

If this is the only special automation you ever will need, then core/webcore is not worth the trouble. But otherwise, it’s a great utility with endless uses.

This is usually called a “toggle.” And I agree, the easiest way to do it would be webcore. :sunglasses:

1 Like