Linking Rule Machine, Mode Manager, Simple Automation Rules, and Groups and Scenes to simplify actions taken when leaving/arriving

I've been wrestling with this problem for a while. As usual, most of the work wasn't in making it work, but making it simple. I wanted to "abstract away" some of the complications, so that making future changes would be simple and wouldn't tax my aging brain. That meant separating defining the switches, lamps and outlets to act on from defining the rules surrounding those actions and separating those from figuring out whether I'm home or away.

Future changes to any one of those three things won't affect the other two, which to me is a win. No need to open a complicated rule to add a new light switch, for example. This is sort of like what goes on in object-oriented programming, where you try to hide implementation details from every place except where it's actually needed. The downside is that you have more pieces to put together, as everything isn't managed in one rule or app.

Currently these are all triggered by an Opple two-button switch in my garage. I'm working on getting reliable presence detection with the Combined Presence app, which I'll then use as a trigger in Mode Manager for Away status.

Note that when I arrive, the first thing the rule does is turn off interior lights (Group Interior Lights), as I have those set to sequentially turn on and off while away to simulate being at home, using Simple Automation Rules with rules restricted to Only When Mode Away. It then turns on some hallway lights. The particular lights may changeā€”when I change my mind, I just have to edit the contents of the affected group: Group On When Arriving. When I leave, I turn off all interior lights, ceiling fans, fountains, etcā€”again, all the details about that is contained in that group (called, inventively enough, Group Off When Leaving).

Questions, comments, criticisms welcome!

Mode Manager

Set mode based on time of day (does not apply when mode is Away)

Day: at Sunrise
Evening: at Sunset
Night: at 11:00 PM
Modes to ignore time changes: Away

Set mode with buttons

Use time settings for return from Away for OppleTwo1Garage button 1 pushed.
Away: OppleTwo1Garage button 2 pushed.

Groups and Scenes

Group Interior Lights lists all my interior lights
Group Off When Leaving lists everything I want to kill when I leave
Group On When Arriving lists the lights I want on when I enter the house at night

Rule Machine

Select Trigger Events

Mode becomes *changed*

Select Actions to Run

IF (Mode is Away) THEN
	Set Away to true
	Off: Group Off When Leaving
ELSE-IF (Variable Away = true) THEN
	Set Away to false
	Off: Group Interior Lights
	IF (Time between Sunset and Sunrise-20 minutes) On: Group On When Arriving
END-IF

Local Variables

Name: Away; Type: Boolean; Value: false

3 Likes

I like your approach, and the fact you outlined it here for others to benefit from. I've tried to adopt a similar approach with my lighting setup / rules on my hue bridge for much the same reasons of ease in changing members on a room / zone or the setup of a scene without needing to reference specific lights.

1 Like

With the groups and scenes, the "Group On When Arriving", is that a group of lights or a scene?

Though not quite the same use case, when I setup my rules in hue I created various scenes, where some scenes would have a selection of lights from a room that were on and some that were off. In my rules I could simply nominate the room and the scene and didn't have to consider the setup of the scene, e.g. switching from Day to Night mode I am transitioning most rooms from an Evening scene to a Bedtime scene.

Additionally, I setup a Current scene that I updated when I transitioned between modes, setting it to the definition of another scene. So, again, when going from Day to Night, I switch my rooms from Evening to Bedtime scenes, but also capture the Current scene as the definition of the Bedtime scene. This meant in my motion rules I could simply reference the Current scene and regardless of whether it is daytime or night time the rule works for both.

Edit:. All that said, the "by mode" options in HE do negate the need for this setup.

If you haven't read it already, you may also find the thread below useful, different community members talking about how they name and organise various aspects of their setup.

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