How to efficiently implement modes

Never used modes, but can see potential use for home/away mode which i'm seeking advice for.

Are there recommended approaches to this, ie can i apply home/away mode globally to enable/disable a collection of apps or do i have to put the mode as a trigger or expression in each and every app that it applies to- then will i have to duplicate each app for each possible mode, ie my kitchen-lighting app for "home" then create another app for the "away" situation.

Be interested to hear people philosophy on this and how they implement it.
there's probably a few tips and tricks you may be able to share.
thanks for advice

1 Like

Multiple ways to tackle this. Simple IF statements or Required Expressions in Rule Machine will allow you to do things based on mode.

Simple Automation, basic rule, and most stock apps have a restriction section where you can disable based on mode. Rule Machine does not but you can use a required expression or if statement. Many community apps also use it as well.

I personally keep things simple with modes that match a typical alarm system: away, day, night. I have seen others have many more modes than that. I do utilize virtual switches to augment things with mode too as again with the stock app restrictions they can also be restricted by the state of a switch. So for example Away mode turns off various lights because I am not home but typically I will return several hours later. But if I am gone for an extended vacation I flip a vacation virtual switch that will disable a few simple automation rules from firing that turn on lights I would only need on if home.

You may get some good info from this older post as this question has been asked a few times in my 5 years on this community:

1 Like

From a worldview perspective (and what about home automation isn't essentially about shaping the world to fit your personal outlook?), I'd argue that Modes align most closely with daily schedule-y things, much like a programmable thermostat.

If literally any aspect of your family life or work schedule has a pattern to it -- when you wake up; when you go to sleep; what you do when leaving the house; and upon return; your preferred light levels at evening time; myriad ways you might tailor rooms of your house to accommodate a party or watching TV, etc.

All of these lend themselves to Modes. If you think of Modes as a master checklist governing apps like RM, Thermostat Scheduler or (my favorite) Room Lighting, then mapping out just what Modes you require should not be too challenging.

Some suggestions: HOME, AWAY, PARTY, VACATION, WORKING, CLEANING (even LEAVING and ARRIVING may have their place, although those are technically more transitional activities, not states of mind).

Hope this philosophical approach resonates with you on some level. It's a big commit!

thanks for the info, everyone. I will start with a simple HOME / HOLIDAY mode (disable boiler functions) for a start before i get too deep.

i had seen that thread but (unless i missed it) wondered if there was a function to control a "group" of selected apps based on a particular mode.

1 Like

I use modes Home, Away, Evening, Asleep. My schedule isn't fixed, so I use switches to change rules. The switches are toggled either by rules or by voice via Alexa. I have an RM rule for each mode change that does certain things when that mode triggers. (Asleep turns the lights out; Away turns the thermostat down; etc.) Really modes can be set up to do whatever makes sense in your particular situation.

What are you looking for as far as controlling groups of apps?

1 Like

Yea, I experimented with using various modes, but ultimately went with the less is more approach. I have four modes: HOME, AWAY, SLEEP, VACATION. I find that day / night is better off utilizing sunset or lux calculations. And, other occasions such as party and guests are better served by virtual switches.

Home and Away modes are all governed by the family Life360 presence. Sleep gets triggered when I plug my phone in between 9:00 PM and 1:00 AM. In the morning, Home is triggered by movement in the kitchen between 5:00 AM and 9:00 AM.

2 Likes

I have several modes: Home, Home(night), Home(secure), Away, Away(secure), and Vacation.

Home - Myself or my wife is present, it is day time, and we want minimal notifications (ie only for doors left open, leak detections, etc.)

Home(night) - Either myself or my wife is present, it is night time (this time varies based on whether I am home alone, my wife is home alone, or we are both home) and we want a few additional notifications (such as motion in the garage, patio, door opened when it shouldn't be, etc)

Home(secure) - We are home but for whatever reason I want to be notified for absolutely everything. Like full on paranoia mode. This mode must be manually activated. And I really only use it for testing and troubleshooting things if I'm being honest.

Away - We have just left (ie no adults are home) but it's only been a few minutes so we want to be notified if we left a door unlocked or open, garage open, but we don't need to know everything). Also this mode is active if we aren't home but someone we know is. More on that later.

Away(secure) - No adults are home so we want to be notified of anything out of the ordinary (motion inside the house, doors/windows being opened, leaks detected, shed outside has been opened, fridge temperature has risen abnormally, etc)

Vacation - same as "Away(secure)" but has some additional lights and shades automations enabled to make it look like the house is occupied.

In addition to these modes, I have a hub variable which controls some mode settings based on whether a trusted guest (like my parents, my wife's parents, a house sitter, maid) is detected.

Here's how it works:
-variable is called "trusted_guest". Value is integer and initial value is set to 0. If the value changes from any other value back to 0, then all normal mode rules are enforced.

-if a "trusted guest" is detected (by means of Unifi MAC address presence notifier, because they've automatically connected to my wifi), the variable value is set to 1 which either does nothing if the mode is "Home", or notifies us that someone has arrived if any other mode is enabled. A trusted guest is somebody who I've manually added to a list of people to be detected when they connect to my wifi.

-if the trusted_guest variable is set to 2, automatic actions are performed including all interior motion notifications are disabled, door opening notifications are disabled, and so it essentially behaves as if we are in "Home" or "Home(night)" modes, except the mode will show as "Away" or "Vacation" depending on the situation.. The "trusted_guest" variable can only be set to 2 if it the value is already = to 1 (a guest is detected by Hubitat) AND they properly enter a security code on a keypad near the front door. OR, we can manually set the trusted_guest value to 2 by pressing an override button on our dashboard in the case that automatic detection did not properly happen. There are 2 special people who can override it themselves by entering their code 3 times within 30 seconds even if they weren't automatically detected.

3 Likes

This is similar to how I view it. Are there parts of the day where you always want things to be the same?

I have:
MORNING
I want default light brightness to be lower and the ramp rate to be slower. I want my speakers to be a quieter volume. I always have the same light scenes on in the morning. I like it a little bit cooler in the morning than the afternoon. Notifications are shown on LEDs on my switches

DAY
Brighter lights, louder speakers/media. A bit warmer than the mornings. Notifications are spoken and shown on LED indicators

EVENING
We are usually cooking at this time, so brighter lights in the kitchen, louder speakers in the kitchen, living room, but quieter in the bedroom

LATE EVENING
Start cooling the house, dim the lights, suppress most audible notifications

NIGHT
Ignore main motion sensor in the bedroom, suppress notifications, cool the house down, prevent multiple rings on doorbell, etc.

Because I always want these times to be the same, I felt it was easier to tie actions to modes than many individual rules.

1 Like

thanks for all the comments and scenarios.
i appreciate there are many scenarios, unique to each user.

I seeking a more generalised approach of how to control/enable/disable apps per-mode.

Is there an app that can run/call other apps? (a kind of "mother" app hosting or controlling "child" apps)

1 Like

I implemented this using Hub Variables where appropriate. Sure, RM and other apps often have the equivalent of "Required Expressions" wherein MODE == gets you the desired pause/resume effect.

But I take this a step further with a series of Boolean hubvars called things like enable_HVAC or enable_Outdoor_Lighting. By altering their true/false value in conjunction with changing MODE – or, more commonly, by manually tapping a dashboard tile or simply as part of an Alexa routine – I effectively stop and start whichever automations include them (e.g. IF enable_HVAC == true THEN yada yada).

1 Like

I have limited use of modes. I currently I have Morning, Day, Evening, Bedtime, and Night, and they are all controlled by Mode Manager to switch at appropriate times. Some of my Room Lighting automations use these to set lights to different levels based upon the time of day.

I have a Disabled mode that I intended to use to turn off all my automations. But I don't actively use it. What I did was set up a bunch of virtual switches that are each tied to different areas of the house that have automations (Front Hall Manual Control, Kitchen Manual Control). All my Room Lighting or Motion automations in those areas are disabled by their respective virtual switch being turned on. I then have a Group called Manual Control that ties all those individual virtual switches together. This means I can disable the automations in a specific area ("Alexa turn on Kitchen Manual Control") or I can turn them all off ("Alexa turn on Manual Control"). I have it set so if I switch to Disabled Mode, then Manual Control is turned on. But I never switch to the mode... it's just easier to use Alexa on the virtual switch.

I have an Away mode, but I don't use it either. I thought about tying it to presence, but I haven't yet. I thought about tying it to HSM to turn on Armed Away, but I haven't done that yet.

I had a Guests mode, but I didn't know how to use that. In the end I thought it would conflict with my Morning/Daytime/Evening/Bedtime/Night modes. In the end, I just disable the automations in affected area (via the XXX Manual Control switches) as needed.

1 Like

Yes. The "mother" would basically be a Rule Machine rule set to trigger on "Mode becomes...". The actions would be "Run Rule Actions..." with each child rule identified.

The children could also be rules to set default volume, lighting levels, enable/disable rules by setting private booleans, etc. There wouldn't need to be any triggers because they would be called to run by the "parent."

Just one method. There are obviously many that can accomplish the same thing.

1 Like

Modes are a special case of Hub Variables, but provide one thing that's not available in other Variables: an enum. By configuring modes, you can pick a list of possible states, then check which of those possible states the variable is currently set to. (I find it an unfortunate limitation that you only get one of these, and hope that Variables adds an enum type at some point.) You could do the same thing with strings, but you then have to be careful that anything checking the variable uses exactly the same spelling/capitalization as the thing checking.

In my home, there are several semi-independent states that I would like to represent this way. However, most of them have only two states and so can be represented as either a Boolean variable or a virtual switch.

  • Time of day / Light level: Cycles based on light level / bedroom state from Night to Dark to Dim to Bright and then back down. I use the built-in Mode for this, as it's the only non-Boolean.
  • Presence: I used to have a separate Away state, which is the common pattern, but that limits the ability to condition outside things on the light level represented by a mode. Instead, I now have a virtual presence sensor (called Anyone) that indicates whether there's a person in the house.
  • Work Mode: Because I work from home, there are certain automations that behave differently if I'm the only one at home and I'm in my office. (The rest of the house mostly behaves as if no one were home, unless I open my door.)
  • Movie Mode: Indicates whether someone is watching TV and overrides lighting behavior. Could be implemented by a combination of mode and TV state, but a virtual switch makes for easy voice assistant override.
  • Asleep: Indicates that not only is the mode Night, but we've actually gone to bed for the night and everything should be idle. Motion after this point is likely a kid who needs something.
  • Babysitter Mode: Indicates that someone is in the house who doesn't feed into our presence sensors; forces Anyone to be present even if no other presence sensors are. Turned on manually by voice assistant, and turns off after we've been gone and returned.

Ultimately, any of these could be implemented by checking a combination of things, but having one rule/app that performs the check and everything else looks at the result simplifies the rules and dramatically simplifies changing the logic for the check. It's the HA version of DRY (Don't Repeat Yourself).

1 Like

Major +1 on the dream of adding enum type to Hub Variables in the future. It's not hard to imagine a variety of workflows that would benefit from this addition.

I don't know to push this kind of feature request to, do you?

3 Likes

I posted it as a feature request a while back, but it didn't really get any traction. The Simple State Machine app is another way to achieve this, though it's a bit heavy in number of virtual devices.

1 Like

I have a mode for when my cleaning angel is in the house. It turns on all the lights. I asked her not to use the wall switches.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.