Easier way to change modes from Alexa?

Migrating from SmartThings where changing mode was fairly easy:
1- create scene "Good Night" that changes mode to Night
2- create Alexa routine "Good Night" that calls SmartThing's "Good Night" scene

Migrating to Hubitat, I ended up:
1- creating a virtual switch Virtual_Good_Night because virtual buttons don't show up in Alexa
2- creating a webcore piston that monitors changes to the switch and when turned on, change the mode and reset the switch to off
3- creating the routine "Good Night" that switches on Virtual_Good_Night

I effectively end up with as many virtual switches as modes I want to be able to switch to, and running into the risk of Alexa turning these on by mistake for "turn on " commands when ASR doesn't resolve the slot properly.

This seems a little complex and error prone for such a basic scenario. Am I doing it wrong? Is there a simpler way?

You don't need webcore. You can use Mode Manager, which is a native Hubitat app. This is how I do it:

  1. Create virtual switch for mode. You can use one switch for multiple modes if you want. For example, I have a virtual switch "Switch - Home". When it's on, mode should be Home. When it's off, mode should be Away.

  2. There's an option in Mode Manager: "Set Mode With Switches." Use those options with your virtual switches.

  3. Set up routines in Alexa that flip your switches on or off.

That's all you need. Mode Manager will take care of monitoring changes to the switches.

Edited to add a screenshot. You'll notice that for mode Home, I have two switches. If either of those switches turn on, Mode Manager will change the mode to Home.

Thanks for the tips. I'll give Mode Manager a try.

The multiple switches for one mode makes me wonder if we could use bit encoding to reduce the number of virtual switches needed. e.g. in your cause going from 3 switches to 2 by having 2 switches with 0 for off and 1 for on representing:

0,0: Away
0,1: Asleep
1,0: Evening
1,1: Home

Potential issue would be race conditions causing an incorrect mode to be selected for an instant, e.g. in this example going from Away to Home would mean flipping 2 switches and potentially the system picking Asleep or Evening for a short period of time.

In any case it would be nicer not to have to create these switches in the first place :wink:

Why don't you like virtual switches? They're free and easy to make! Trying to bit code it just seems overly complicated to me. I'd never remember what switch has to be on or off for any give state.

I have quite a few virtual switches that I use for all kinds of things. They trigger Rule Machine rules, allow or stop automations, trigger Alexa routines, send states from one Rule to another, or from one app to another. I find them incredibly useful.

I have two switches for Home mode because I have an Alexa "Good Morning" routine that does some stuff I want to have happen when I wake up in the morning, but I'm already "home" because I slept there. "Switch - Day" is on for Home and off for Asleep." "Switch - Home" is on for Home and off for Away. Having two switches for Home lets me switch to Home from both Asleep and Away.

Your use cases are probably different from mine, so you should set it up however makes sense for what you want to do. One of the things I find very powerful about HE is how many ways you can accomplish a given result. It's very versatile. As you poke around in Mode Manager, you'll see that there are multiple ways to change mode.

P.S. I came from SmartThings also.

I heavily use virtual switches in other situations. For example my setup has a "Cameras" switch that when switched turns on|off all the cameras in the house.

I'd rather not use virtual switches to encode modes because we're leaking internal implementation details to Alexa and she could incorrectly interpret a "turn on" command to target one of the virtual switches instead of the intended device (bad speech recognition due to background noise, etc.). With a routine, I can make sure the user understands what's going on (e.g. have Alexa say "turning on the Alarm" before changing the mode). With a "turn on" command, she'll just say "Ok", and then in the previous example the user gets surprised 10 minutes later when the alarm starts blaring.

A lesser issue is that we essentially end up duplicating data, e.g. "mode==x" is stored in 2 places that if not kept in sync could cause subtle issues.

That's one reason I have my switches named "Switch - whatever." Alexa is not likely to misinterpret a request to turn on a light, say, and turn on a switch instead. (All of my lights are named "whatever lamp" or "whatever light.")

You can have multiple ways to trigger mode. I also trigger mode based on presence and on time of day. And, if Alexa is down, I can still toggle the virtual switches if necessary to get mode to change. The other things that my Alexa good morning/good night routines do would also have to be done via the HE interface. But that doesn't happen very often and it's not a big deal. Rules, etc., that are on the HE hub will continue to work just fine because that's all local.

I haven't had any problem with virtual switch states getting out of sync between Alexa and HE. They might, I suppose, if the internet were down and Alexa was unavailable. But in my experience they sync pretty fast once everything is back on line.