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!
Day: at Sunrise
Evening: at Sunset
Night: at 11:00 PM
Modes to ignore time changes: Away
Use time settings for return from Away for OppleTwo1Garage button 1 pushed.
Away: OppleTwo1Garage button 2 pushed.
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
Mode becomes *changed*
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
Name: Away; Type: Boolean; Value: false