I’ve enjoyed HA for 2.5y now and I’ve accumulated a longish list of 50+ automations, which are now due for a complete restructuring.
A question that has been bugging me - is it better to structure automations from the perspective of ‘single trigger - multiple actions’ vs a ‘distributed’ approach in which each automation completes one single task, but one event triggers multiple automations?
Example:
trigger - home occupancy switches to ff
single automation approach - go over each light in each are and turn them off one by one
multiple automations approach - have separate automations for each area/light that listen for the same trigger;
Besides the organisation preference, which I believe is highly subjective, is there any performance impact of each approach?
I split out some of the actions into scripts, so I can have different trigger types (single/queued) with identical function. You need to look at how other potential triggers or other running automations may effect how you want the actions to behave, and adjust the accordingly.
Certain actions take time to complete, but you may want multiple actions to occur simultaneously, so that needs to be taken into account. If one of the actions is a slow dimming of the light, and the next is the closure of blinds, there may be a large and unacceptable delay if they are queued.
Also there are huge benefits to code maintainability and readability, so these should be prioritized. I try to write down the flow of an automation on paper before I code it, since that allows me to see potentially problematic interactions with triggers and actions stepping over eachother, like when you have a “go to sleep” light effect which dims lights over time, then shuts them off, but you also have an automation that takes the light state as a trigger.