Virtual Momentary Off Switch for Harmony?

For my Harmony/Alexa integration I would like to be able to say “turn off TV” and have it trigger a virtual momentary switch. Has there been an app written that accomplishes this?

The setup would be a momentary switch for each harmony activity to turn on and a momentary off switch to end the active activity. All this is doing is avoiding giving an “on” command to turn off activities.

It won’t work with a momentary switch because by definition a momentary switch immediately turns on and then off.

Instead, you need to use a binary switch like the “simulated switch” device type. This is detailed in the Harmony/Alexa FAQ.

Alternatively, you can use a momentary switch, but then you have to say something like “Alexa, turn on Exit Routine,” where “exit routine” is the name of the momentary switch and it is the switch coming on that triggers the power off activity.

A binary switch is like a traditional light switch toggle. It has two states, on or off. When you turn it on and it stays on until you turn off again.

In contrast, a momentary switch is like a traditional doorbell button. It is off most of the time, and activation causes it to come on for just a moment and then return itself to the off. This is why it doesn’t really make sense to turn off a momentary switch. It is already off.

You will find additional detail discussion of how to synchronize off in the harmony/IFT TT project report, even though you will probably not be using IFT TT is a middleman, but instead will use the harmony trigger smartapp. The switch configuration and power off protocols are the same though.

1 Like

Thanks @JDRoberts, I’m familiar with the current options and have played around with both types of switches in the integration. I was mainly wondering how hard it would be to alter the momentary switch device type so that its definition is reversed, that way it is always on and momentarily switches off on command. That way I could use an ordinary momentary switch to turn on or switch between activities and have a “reversed” momentary switch work with a “Alexa, turn of TV” command (where TV=end activity)

Sorry for making you type out that detailed explanation again :pensive:

You can’t quite do it the way you’re describing. That’s because the device type is the way commands are sent from the controller to the device.

But somebody did write some code to create a virtual toggle where if the switch was off it would turn on and If the switch was on it would turn off.

That’s not a momentary, where by definition the switch cycles through two states, which is what will always mess up harmony. (An always-on virtual momentary switch would still send two commands, firstly off then on. So you wouldn’t get the result you wanted.)

If you’re just trying to avoid the maintenance effort of putting the “on” into each harmony activity, then the virtual toggle would do it.

Not sure where that code is though, you’ll have to search the forums for it.

So I would have virtual momentary switches for each activity and a virtual binary switch for “activity off”, create a harmony trigger that activates “activity off” when turned off and then a smart app that will flip that switch back on like useless box?

Useless Box

Sure, that would work if you just have your useless box switch app subscribe to the binary switch going off and turn it back on. And don’t have turning it on do anything at all. That way it would be ready for the next “off” command.

But then you have to always have the binary switch turn your devices off. If somebody grabs the button remote and turns the TV off you might be out of sync. Because you never touched your binary switch that way.

( harmony used to have a power off activity associated with the off button, but they don’t anymore. Now physically pressing the off button on one of their remotes turns off whatever entertainment activity is currently active.)

What most of us do instead is to add turning the virtual binary switch on as a start step to every harmony activity. That way no matter what you do to turn things on, the binary switch is sitting ready to turn the master device off again.

For example, I have voice controls for:

“Turn Netflix on”

Turn ESPN TV on"

“Turn DVD on”

“Turn Roku on”

Or my housemate might turn the TV on from the harmony button remote or from the harmony app. It doesn’t matter, because harmony is based on activities, and we have turn the virtual binary switch (called “theatre” ) on in every activity.

Harmony will not turn off a device which is needed in the next activity. So it just stays on the whole time.

Then when I use the voice command “turn theater off” that triggers an activity which turns off the master power device, in my case, the TV.

I can call the virtual binary switch whatever I want to in echo using groups, so if I wanted to call a TV I could. As long as I didn’t have another switch also called TV.

In my scenario, I turn on content and I turn off devices. So it’s easy to remember and feels natural for us even though we don’t have one switch that is both turned on and off by voice. We never try to “turn on theater.” That’s only used for off.

It is possible to get an out of sync condition this way where my housemate uses the button remote to turn the TV off, the virtual binary switch for theater might be left on. But I don’t care. It’s just like your useless box app. Being on is unimportant except that it needs to be on right before I want to turn it off by voice. I don’t check the status on that or anything.

If I did want to check the status on that it gets trickier, and that’s where your useless box smart app would fill that gap. But then you have the synchronization problem of someone using the physical remote button.

So just comes down to exactly how you are going to use it and which gaps you need to fill.

At my house, I use voice for the TV and my housemate uses the physical remote. So keeping those in synch is the biggest issue for us. If you never use the physical remote and you want to reduce the effort it takes to set up new activities, then the useless box approach would be better.

I see what you’re saying, and I guess it depends on which devices you use. Right now I only use a new Apple TV and an Nvidia Shield (android). Harmony doesn’t work well for these because of the voice control features and the new touch-pad on the apple, so I really only use harmony to turn on and off activities and get everything on the right input.

I wasn’t able to find the code you mentioned but “Smart Lights” should do what I am looking for (Useless Box). I’ll know in a little bit if it works.

1 Like

The trick I used with “Smart Lights” worked great. My power button is on the back side of the TV so there isn’t much chance of anything getting out of sync and now I can say “Alexa, turn off TV” and my virtual binary switch gets turned back on and ready for another turn off command.

1 Like

Going back to your original question about creating a momentary “off” button. I created one by using the code for the “Momentary Button Tile” device type. I just switched the sequence of send events in the push method:

def push() {
sendEvent(name: “switch”, value: “off”, isStateChange: true, display: false)
sendEvent(name: “switch”, value: “on”, isStateChange: true, display: false)

The initial state will be Off though but if that’s a problem you can always set it to the right state during initialization. I have this tied to sending an Off device command to the Harmony Hub so I can tell Alexa to “Turn off TV Power”.

Thanks, I thought it might be that simple originally but I have to be told what to do with code lol.