Consolidating Automations

Hey fellow HA users! I just wanted to check and see how everyone else has approached this configuration.

Do you like having automations consolidated using templating, or do you like to keep each room as an individual automation? Example, do you have a different automation for motion in the living room and dining room, or do you like having them in a single one if they’re all related to turning on a light?

Currently I have as many consolidated as I can - One for motion detected, one for occupancy, one for manual switch presses, etc, but this can easily complicate it if I’m trying to troubleshoot a single room.

I never combine automations for anything unless it’s fairly simple, it makes sense to do it and it doesn’t complicate troubleshooting.

1 Like

If the action is different, or the conditions are different, then I usually make a separate automation. If multiple triggers do the same thing I usually combine them in one automatio so I can easily see which things do that particular thing.

For very simple automation where I can for instance easily template on/off then I will, but not if I need “if trigger is x do this else do that”, or if I need to test for triggers to see what conditions apply.

If I need multiple automations to do the same multi step action, I’ll break the actions out in a script.

I avoid wait for triggers for anything that takes longer than a few seconds. They too get their own automation.

That way I have very few long, complex automations. If anything misbehaves it is quite easy to find and fix.

1 Like

Hello famousjs,

There is no wrong way,

(Unless you are trying to enable and disable a bunch of automations or expecting your automations to run for more that a few minutes that is, IMO.)

What makes the most sense to you and you feel comfortable maintaining, do that.

As SG said, there’s no right or wrong way… as long as you can keep track of it. It’s also going to depend on your house’s layout, the type and quantity of devices you are using, and how you and your family utilize different parts of the house.

I have a pretty even mix of single-purpose automations and ones with significant branching and templating, but I generally keep any given automation to one contiguous region and one general concept. For example, our dining room, kitchen, and pantry areas form an L-shape region so I do all their lighting together in one automation because it can be annoying if lights are turning on and off repeatedly when we’re working near the border between areas.

One thing that can be a common source of frustration with consolidated/complex automations is that people don’t think about the edge cases where multiple branches may need to run at or near the same time. When consolidating automations it’s important to spend a little more time thinking about the automation mode to make sure that one mode will work for all the cases.

1 Like

I have two homes and strive to keep the automations / templates identical. With each house, I strive to keep automations / templates identical (for example light control.) I also want to be able to make a change once and have it apply everywhere. Having these as individual automations make it much easier to look at trace logs when something doesn’t work.

So currently I have the package defined externally to HA. Run shell script to substitute the correct entities in and create a new package. Blueprints could also be used for a similar approach but they do not support templates (helpers), and I find most automations also require template, input numbers, etc. in summary one master package gets replicated out into dozens of packages across multiple HA systems.

These are great! I started off really trying as much to consolidate my automations, but like may here mentioned often times when i need to troubleshoot something it’s harder to do that. For example, my setup I have each room with an “_occupied” helper. (i.e. input_boolean.living_room_occupied).

I have an automation that detects presence, such as motion, or the TV turns on (apple TV) or a bed sensor has detection, and it will mark the room as occupied. A second automation will turn on the light if and when a room becomes “occupied.” This way if a motion detector thinks there is no one there, it won’t turn off the light unless it considers the room unoccupied. Same thing for a manual light switch press. a “input_boolean.living_room_manual” makes it so if a light switch gets pressed manually, it turns that on and nothing will turn it off unless the switch is hit again.

For the occupancy automation, the triggers are all of my motion sensors for every room (in one automation). If detected, it uses the following template to turn on an input_boolean:

entity_id: input_boolean.{{area_name(trigger.entity_id)}}_occupied

Turning off based on the sensors in my house, it has a condition:

{{ 
states('input_boolean.' ~ area_name(trigger.entity_id) ~ '_manual') in ['off'] 
and 
states('media_player.' ~ area_name(trigger.entity_id) ~ '_apple_tv') in ['standby', 'off', 'unknown']
and
states('binary_sensor.' ~ area_name(trigger.entity_id) ~ '_motion_sensor') in ['off', 'unknown']
and
states('input_boolean.' ~ area_name(trigger.entity_id) ~ '_sleep') in ['off', 'unknown']
and 
(
(expand(state_attr("input_select." ~ area_name(trigger.entity_id) ~ "_connected", "options")) | map(attribute='last_changed') | reject("<", now() - timedelta(minutes=2)) | list | length > 0) 
)
}}

That way it only considers the room unoccupied if everything is off that could be off, even if that room doesn’t have that sensor. The last part of that is what I’ve been messing aroudn with to reduce false positives if I really haven’t left the room. It only turns it off if a connected room (a input_select with a list of adjacent rooms) has detected motion or been occupied within the last 2 minutes, or an adjacent room is currently occupied.

This does make for a pretty satisfying setup, since every device has a configured area, but as you can see it really does complicate things if one room really isn’t acting the way it should be. I really only have 4 or so automations with it set up this way and I can just add a new sensor to the one automation and the rest of the manual and occupancy automations function as normal.

I was just curious to see how others had it set up.

1 Like