Simulated Switches and the Stock SmartApps - a Question about Workflow

With the move to 2.0, I have resolved to simplify things and take advantage of SmartThings apps and integrations as much as possible. Since none of these can talk to HAM Bridge, I have set up a number of virtual switches that do that.

The problem is presented in the following scenario:

A virtual switch, when turned on, calls HAM Bridge to run a script that turns on a home theatre system, and starts a source playing. When turned off, just the opposite (it turns everything off).

The problem I am working with is that if the switch is currently in the off state, then an OFF event is not sent from a Routine that is set up to turn that switch off, and I need it to be due to the possibility (heaven forbid) that someone turns it on manually.

My current workflow is something I consider little better than a kludge at synchronization that I won’t bore you with. The ideal solution is just to have the virtual switches receive and execute the OFF handlers even though they are off. I have other switches that do this with filter events false, but these don’t behave the same.

Thoughts? Am I missing something simple, or is this just not going to happen with the “Turn these switches off” in the default SmartApps?

I used to run into this all the time with hello home actions in the previous version of the app.

I found the easiest way around it was to make two virtual switches, both momentary, one that I used for turn on and one that I used for turn off. That way they could never get out of sync with any other method of controlling the device because they’re always off and ready for the next on instruction.

1 Like

Depending on if your integration goes both ways, can your system send a command to Smartthings to turn that switch on? For example, all my Harmony activities have an action that turns on a virtual switch labeled “Off”. That way even if I Smartthings/Echo didn’t initiate the activity I can still end it by turning that switch off (or telling Alexa "turn off the system/harmony/etc). Again I’m not sure what abilities your bridge has, but that works well for harmony.

@JDRoberts has the right solution. Momentary Button Tiles have the very cool property of looking like a switch that’s off, that automatically turns itself back off after you turn it on. @JDRoberts’s solution simply inverts the sense of one to get the same feature for off.

Yes… and that is the ‘kludge’ I have currently implemented. And while it has the advantage of preserving state info in the interface, it involves changing a lot of code in my various iRule remotes, giving up local control, and I really don’t need the state info (plus it does not address some manual operations).

Yup, that looks to be the simplest way to skin this cat. Thanks!

Now to undo this mess that I have done.

1 Like

In your case that does sound much more complicated. I do use momentary switches for all my “on” activities. I have one “off” binary that turns the system off through IFTTT. I mainly did that to avoid havin to say something clunky to Alexa like “Alexa, turn on ____” when trying to turn off the entertainment center.