Getting Harmony to work properly with Smart Home Controls - problem with on/off state of switch

smartlighting
harmony
wallswitch
automation

(RT) #1

I’m trying to solve a challenge related to controlling the on/off state of smart lights (home control) and would love to get thoughts and advice please…

I have programmed one of the Harmony light switch buttons (bottom left on the remote) so that when short-pressed it turns on a Virtual Switch in SmartThings and when long-pressed it turns off the same Virtual Switch. Then in SmartThings I use webCore I take a certain action based on whether the switch was toggled on or off.

That all works perfectly fine, except there is one significant issue… Harmony apparently keeps track of the status of whether the light switch it is on or off (and assumes only this one switch can change the on/off state), and will not send an On command if it thinks it is already On, and will not send an Off if it thinks it is already Off. For instance let’s say the switch is in the Off position and the lights are really off. I short-press for On and Harmony sends the On command as it should and all works well.

But here’s where the issue comes in… I have other ways to turn this switch on and off outside of Harmony. For instance via Alexa and a push button home control / SmartThing button on a wall (not a physical switch). So let’s say the lights are on, and I now use Alexa to send a voice command and tell it to turn off the lights, and it does. So far so good. But at this point, Harmony thinks the lights are still on, even though they are off, because all it knows is that the last time it’s button was pushed was to turn them on. So a little later I then want to turn the lights on. If I short-press the light button on the remote, nothing happens! This is because Harmony has outsmarted itself. It thinks “oh they said to turn the lights on, but they are already on, so I won’t send any command.” And the lights stay off. The only way to get the button working then is to long-press it so that it sends a Off command, thinking it just turned the lights off, even though this actually did nothing since they were already off. And then a few seconds later I can short-press the light switch button, and then it sends the On command and the lights come back on.

Likewise I have the same exact issue in reverse - if I turn the lights on with Alexa or some other automation, Harmony things the lights are off, so when I then long press the button it doesn’t send an off command, so I then have to short-press to send a On command, which effectively does nothing since the lights are already on, then a few seconds later I can long-press and it sends and Off command and the lights go off.

I’d love to find a solution so that Harmony is not tracking the “state” of the on/off (or a way for me to programmaticly change its state) and if I short-press it always sends an On and if I long-press it always sends an Off. This would solve the issue 100%. However I don’t think there’s a way to get Harmony not to track the state. In which case I’m wondering what a possible workaround would be. The current workaround (aka short-pressing for On when lights are already on and then long-pressing for Off to get them off, and vice-versa) is pretty annoying. Is there some sort of trick or better technique?

Edit: Just to be clear, my goal is to continue to be able to use the same light switch buttons (bottom left) on the remote to turn the lights on and off. So any technique that requires me to use another means besides these buttons will not solve the challenge.

Thanks!


(Steve Jackson) #2

Create an activity for these lights in Harmony (if you already haven’t). Make that activity visible inside ST. It will show up as a Harmony Switch (on/off). Turn that Having switch on and off to control your lights. That way it will always be in sync. Below is a Harmony Switch visible in my hub. It turns on the activity that turns on my TV, Cable Box and Receiver.


(RT) #3

Thanks for your message. I’m not sure I am following you. Will I need to use that Activity to turn the lights on and off? The key point that I should have emphasized (I will edit my post now) is that I want to continue to use the same Home Control light switch button on the remote (bottom left switch buttons) to turn the lights on and off. Also I don’t see how that will make sure everything stays in sync. Seems like it will have the same problem with it not realizing that other switches outside of its view may have changed the state of the light without it knowing.


(Steve Jackson) #4

You set the remote (I’m assuming it’s a Harmony remote) to activate the “light activity” that turns your lights on and off. (Not the virtual switch, which you won’t need anymore) It will always stay in sync because your using Harmony to turn it on and off. If you expose that Harming activity in ST you can turn the same activity on and off within Smartthings.

It’s the same as turning a TV on and off. I can do it using the Harmony Remote, the ST app, or Google Home but it’s the Harmony hub (you have a Harmony Hub, correct?) that is ultimately doing the work so it knows what the status is. If you have a wall switch for these lights too it will get a little more complicated.

If your still unclear I’ll see if I can find a few minutes to create an activity for my living room lights and take some screenshots for you to see.

Another thought, did you expose the lights you want to control to Harmony? If you did you will be able to turn the lights on and off in the activity.


(RT) #5

Thanks Steve. Yes, it is a Harmony Ultimate remote with Hub. Well, my lights are not really on an on/off switch. Instead to turn them off I call a LIFX command that sets them to 0% and to turn them on I set them to 100%. Its more complex than I’m describing here, because that part of the picture doesn’t really matter.

I originally had the Harmony controlling the lights directly, but ran into reliability issues, which I solved by going to the virtual switch and letting webCore do the smart side of things when the switch got flipped.

I’m still not sure how the Harmony stays in sync when there are other ways such as Alexa and other smart automation that changes the lights to be on/off based on a variety of conditions.

What I mainly an looking for is a way to work around the “state management” that the Harmony is using, which it gets wrong, and causes the issue. I was thinking that maybe I can use two of the home control buttons on the remote - one to always turn it on and one to always to turn off. And make each a virtual toggle instead of a switch. Maybe then Harmony will be smarter about things and know that since it is a “toggle”, as opposed to a “switch”, that it needs to send the command regardless of the state?


(Steve Jackson) #6

Since you already tried having Harmony control the LIFX and it wasn’t reliable than this wouldn’t work for you.

As for your original question about keeping the bulbs in sync with Harmony, I think the only way to do that is too have Harmony control the bulbs, like you did originally. They would stay in Sync because ST and Google (Alexa) would be asking Harmony to turn them on and off so Harmony always know.

I have several smart bulbs in my house that are controlled by wall switches (the switches are installed with no load hooked up to them), the ST app and Google Home. Not Harmony though. I will look at my rules over the weekend and see if they could be used in your situation. I’m not seeing it work at the moment but I’ll look closer. I keep everything in sync using various Smart Lighting rules.


(Steve Jackson) #7

As for using 2 separate buttons on the remote I’m not sure that will work. I haven’t found a way around the Harmony thing about keeping the activity active until turned off. I’m really not a fan of that feature either.


(RT) #8

Thanks Steve. I do wonder if there is some trick to working around its state management. For instance, I could make all my other commands outside of Harmony (Alexa, smart switches etc) do something any time it turned the lights on or off. So if there was a way to change the state of a button inside Harmony, I could do that.


(Steve Jackson) #9

I’ve been thinking about it while sitting here watching Netflix. I may have an idea. I think I will have a few minutes to try it tomorrow. I’ll let you know.


(Olivier) #10

Can you set the remote to send “off” wait 1s then “on” to switch on, and “on” 1s “off” to switch off. It will always send the 2nd command.
And then put a delay in your webCoRE. Only switch if no command received in the last 2s


(Steve Jackson) #11

See if this will work…

You will always turn on the LIFX bulbs using the virtual switch regardless of what rule turns then on.

IF virtual switch is on and <LIFX bulbs are on
Turn off virtual switch
Turn off harmony activity
Turn off LIFX bulbs

IF virtual switch is on and <LIFX bulbs are off
Turn off virtual switch
Turn off harmony activity
Turn on LIFX bulbs

The Harmony activity that turns on the virtual switch should show up in ST as a simple on/off switch and you can turn that on and off just like any other switch.

The only thing I’m not sure of is if you can look at the LIFX and tell that it is on in WebCore. If you can, great. If you can’t, you could add another virtual switch that you turn on and off with the bulbs and test to see if it is on or off.

I am probably missing something here but I think this will work. It’s similar to how I handle my smart bulbs that can be controlled by the wall switch that is but physically connected to them.

I think you could also do this without the virtual switch by just turning on the Harmony activity but since you were already using the virtual switch I used it too.


(RT) #12

Thanks. However the Home Control buttons, such as the Light switch button in the bottom left I want to use, does not have the ability to run commands or macros. The way they did home control buttons is weird in that regard - they act different than the other buttons. So Home Control buttons are forced to send an On command for short-press and Off for long-press. And you can choose only one device or groups of devices that it will turn on and off. Therefore there is no way to make it send more than one command.


(RT) #13

Thanks Steve. However I’m not sure how this helps, because ultimately I need to turn the lights on/off with the Smart Control button (and not via a Harmony Activity). And then we are back at the same issue - it is tracking state.


(RT) #14

UPDATE: OK so I went back to square one and change the Smart Control light button from flipping the virtual switch and having webCore turn the lights on, to just having the Smart Control light button controlling the group of LIFX lights. And it works and handles the state problem just fine! So if the lights are on and I turn them off via another means like Alexa, I can do a short-press and they come back on.

So then I was scratching my head - why did I abandon this approach a year or so ago and move to the virtual switch approach, since it is more complex (involves creating a virtual switch and webCore pistons to do the leg work).

I then remembered there were two reasons:

  1. Sometimes ST would lose a connection to the LIFX lights, and in those cases the lights would stop responding to the Home Control button completely. It would be fine for months and then the button would no longer work to turn the lights on and off. And I’d have to spend hours getting Harmony to see the LIFX lights again. So finally I had enough and went to the virtual switch approach. I never had an issue with it since, except this created the tracked state issue.

  2. When I do a short-press I want the lights to come on 100%. However the last time they were on they may have been at 25%. For example I sometimes have the lights at say 25%, then turn them off. When I press the Home Control button, I want them to come on at 100% always. But in this case, when Harmony sends the On command, it turns them on but they come on at the last % brightness used.

If I forget about issue #1 and just hope that things are more stable now with Harmony and ST, that solves the state issue. The question then is how to make it so that the brightness comes back at 100%. The only ways I can think of, once again, involve using a virtual switch! So then we would be back at the state problem. This is how I do it now - the virtual switch calls triggers webCore to recall a LIFX scene, which has all the lights set to 0% for off.

So it seems I am stuck. I either solve the state problem by having Harmony control the group of lights directly (instead of the virtual switch), but then the lights only come on at their last set % brightness, or I can have the lights come on at 100% by using the virtual switch and webCore, but then I am back to the state problem.

Any ideas? Thanks guys!


(Steve Jackson) #15

I’m getting ready to go out but will write the activity for Harmony and the Piston for WebCore either late tonight or tomorrow. I’ll attach screenshots of the Harmony activity and the Piston with the backup code for you to play with. I think using the approach I outlined will give you everything you want, including 100% turn on and not have to deal with the possible instability issues.


(Steve Jackson) #16

I finally see where my disconnect is. I don’t have the Ultimate Remote. This evening I read a little about it and re-read your description of how it is set-up. I apologize. I made some incorrect assumptions on how that Ultimate Remote operates.

I honestly can’t see anyway to make this work without having the state issue or the brightness issue.

You would think that Harmony would ignore the state on the light buttons. I really can’t see any reason for it unless you can use the same button (i.e. short press) as a toggle.

Again, sorry to waste your time on this today.


(RT) #17

Thanks Steve for all the help. No worries. Yes these Home Control buttons work differently that the others - for instance you cannot tie it to a macro. At any rate, there doesn’t seem to be a workaround. So I’ve left the light button tied directly to the group of LIFX lights. This has the downside of always turning the lights on at their last brightness level, whereas I want them always to come on at 100%. However, this is better than the situation with the original issue I was trying to solve. And this current approach has a nice (big) perk in that it turns the lights on and off nearly instantly. My other approach took a second or two after the button was pressed, because it had to trigger the virtual switch and then webCore had to pick up on that and then make an API call to LIFX to set the scene that brings the lights on a 100%. Thanks again to everyone for all your help!


(Steve Jackson) #18

Hey HDGuy, I was sitting here working on something else and I thought about your LIFX bulbs. Are they controllable through ST even though you have them tied directly to Harmony? If they are, couldn’t you create a smart lighting rule that says when the LIFX bulbs turn on you immediately set them to 100%.