Harmony Hub -> Sleep Mode

Before I go to sleep every night I watch tv. It would be nice if I turned off my tv via Harmony Hub Remote and it then automatically change my ST mode to “Sleep”. The only way I think this is possible is for a SmartApp to run every minute and poll the Harmony Hub to see if the last action was Power Off (which I don’t even know if it can do since I am powering off via Harmony side of things?). Is this even possible???

Create a virtual switch in ST, call it “media center” or the like.
Turn that on and off within your Harmony activities.
Then use that switch within ST.
That’s how I have been doing something similar.

Also there is no polling method for the harmony hub, refresh however works, so I’ve modified pollster to allow selecting devices that also include refresh, this at lease keeps the current harmony activitie in ST up to date.

Thanks @Mike_Maxwell. When you say turn that on within your Harmony activities, I typically turn on Harmony Activities through the physical remote and not ST. Will this still work in this case? I assume you mean program my Harmony Activity through the integration the other direction to (Harmony -> SmartThings? If so, then that should work.

I actually have never created a Virtual Switch before, so I am unfamiliar with it.

Yea, that’s pretty much it, you create a virtual switch (a dummy switch in ST), bring that into the Harmony as a SmartThings switch device.
You then include that switch device into your start and end activities on the harmony side.
When you use your harmony remote, harmony will turn this switch on and off in ST.
From the ST side now you have a device (a switch) that you can use in your ST actions/smart apps.
The state of this device (on/off) will be controlled by your harmony remote. This fake switch doesn’t do anything in ST, other than reflect the state of the activity it belongs to in harmony.
To create a virtual switch in ST you will need a developers account and have to log into the IDE. The virtual switch already exists as a device template in the ide.

Nice! Currently due to the integration broken with the latest Harmony firmware, I don’t have the hubs loaded into ST. Do I need that working first? I assume so to assign to the virtual switch.

Yea, you have to wait…
You can add the switch to ST, but that’s it.

BTW the reason to take this route, is that unlike most devices in ST, the current harmony hub device doesn’t produce an event when the activities are changed, at least I’ve not seen it.
Not sure what the issue is there, but if the harmony device did produce an event as it should then there would be no need for the virtual switch, as a smart app would be able to subscribe and get updates on the current harmony hub activity as they change.

Just out of curiosity, what is the name of the template in the IDE for the virtual switch? I can’t seem to find it.

On/Off Button tile would be the bad boy.

I know I’m one of the lucky few who has fully operational integration of Harmony and ST, but can’t Harmony authenticate with ST even if things are broken on the ST side. From your Harmony app, I think you can add ST, authenticate, and then bring lights/switches into Harmony. Harmony will just send cloud-to-cloud calls into ST regardless of whether ST can see the hub or not. This way you could operate the switch @Mike_Maxwell references from your remote. Then just bake in what you need ST to do based on that switch.

I’ve done this for a few different things to give my Harmony remote more control of my home.

I actually think your right. I do have my integration working FROM Logitech to ST. I have buttons programmed on the remote to turn lights on and off and I now have created a VirtualSwitch called “HarmonyHub-LivingRoom”. Now I just need to program my Harmony Activity (I cannot do this part until I am home since you need to be on the same network) to turn this switch on and off properly. Then I just need a smartapp that changes the mode to “Sleep” when that switch is turned off during a particular time frame (let’s say 9pm to 11pm". Do I have this right?

That should do it.

You may want to use a Momentary switch for this use case, so you avoid state issues (ie. to turn the switch off, it needs to be on). A momentary switch will turn off immediately after turning on, so you could have your Power Off activity turn the switch on, and use either the on or off event to trigger your Sleep mode in ST.

Thanks again. I am struggling to find a SmartApp that will trigger a mode based on the state of a Switch. Do you happen to know of one?

I don’t currently use Modes/Hello Home in my setup, so I don’t know much about it. There should be a way to trigger it though.

Look for a SmartApp called the Big Switch For Hello Home Phrases. It should be in the shared apps in the IDE

Thank you sir. Still getting used to the IDE. Now there is a published app and shared app place and I forgot there was 2!

Just tested this and it worked perfect. No need to get Harmony integration working. Impressed with how useful virtual switches can be!

The other thing that works with this is if you want to control Harmony with ST, you can use virtual switches to run harmony commands using IFTTT

When I press my Good Morning Hello Home button I have an IFTTT rule set to turn my TV on.
If HH-ImBack switched on, then start Watch TV activity

I have something similar tied to goodnight

Out of curiosity, why not trigger sleep mode from ST and have ST turn the TV off for you?

I go to sleep at different times every night :). Besides, I can’t initiate this from ST since the Logitech integration is broken…

Because as of right now, ST won’t discover my Logitech hub, so the only way to control it via ST is using IFTTT as an intermediary. The other direction (Logitech-> ST over the net) works fine

Apparently Logitech broke local discovery on their device in the latest FW and we have to wait for a new one