Logic for "Home Modes"

I’m wanting to implement some “Home Modes” (Home/Away/Asleep/Vacation/etc) that other automations can check against and adjust accordingly. For those of you who have set up similar setups, I’d like to know what kind of logic goes into switching to different modes, aside from the obvious push a button or tell Alexa.

I’m not looking for YAML code, just some thought logic on automatically switching modes. For example, if it’s after 9pm and both phones are charging, switch the mode to “Asleep” or If we are not_home and guest mode is off, switch to Away. That kind of stuff. Just curious what everyone else is doing in this regard.

I use it both my wife and my phone is away turns to away mode and if one of us arrives turns to home mode. For sleep I have a script which turns off the lights, checks if the garage and front door are locked and announces the weather, next appointment on my calendar and my current alarm time to my bedroom Sonos speaker. This one I trigger manually because my bedtime is never the same time. Sleep mode also prevents other automations from running like severe weather or the lights from turning on (in the event our phones somehow turn to not_home and back to home.

  • Evening triggered by light level (turns on downstairs lights and office)
  • Night triggered manually by HADashboard or Alexa (turns on upstairs lights, turns off downstairs lights, enables motion lights downstairs, soon will trigger alarm coverage of perimeter and motion in the basement and garage)
  • morning triggered by motion downstairs after 5am, puts on morning lighting and will disable alarm. Morning is optional and with not trigger if Day happens first
  • Day triggered by light level, turns off all lights.

After some thought I didn’t make being away part of the mode system as it would potentially double the number of modes, so I treat it as a separate state and act on changes of its state based on the house mode.

Still looking for a sensible way to autmatically trigger Night as it varies widely.

This is my logic:

Morning, Day (or away), Evening, Night, and QuietNight

Also, make a distinction between Weekday and Weekend.

Vacation is handled different.

#Set Morning if was night and between 6.30 and 9

#Set day if morning or Evening and between 9 and 15 and empty house

#set Evening if morning or day and between 12 and 19 and not empty house

#set night if evening and between 19 and 6