Create Per Trigger Action in Automations UI

When I started with HA I created a lot of simple automations (porch lights on at sunset, porch lights off at 22:30 and so on). Soon the list of automations became a bit of a mess and hard to find things. Many of these separate automations are either doing the same thing or the opposite of another.

I have recently started to try and cut down my automations and done things like create a single porch lights automation which combines both the original automations into one and uses trigger IDs to determine what action to take.

With two triggers and if/else automations works OK but is a little long winded to do something so simple and with more than two the choose action needs several clicks to add new options, then a condition and then an action.

Just thinking it would be really handy if there was an automation that essentially gave you an action by trigger. So you add three triggers and then add this action, you are presented with one section for each trigger where you can set the action(s)

Just purely some glitter in the UI as the you can achieve this in yaml already just would be better a UX if HA did some of the work for you

I think what you are referring to is called Blueprints. Another way to do this is automation calling scripts . Another way is to call scripts that have fields so you can send trigger data to turn on whatever triggered. There is also calling script blueprints with fields and/or with inputs. All these will use one set of code to do variable actions.
Not sure we need more ways of doing that.

Blueprints allow you to create repeatable automations which I have used before to implement the same automation on different entities. I am suggesting a new option in the UI that would simplify creation through the UI.

Automations will do what is needed already but there seems to be an lot more clicks needed to achieve and I think this drives people to create lots of small automations (which then becomes a bit overwhelming and I think this can put new users off).

I am suggesting that in the actions menu you have a “per trigger” or some form of better description that would create one block with a separate block for each trigger. I believe this would allow new users to create better automations.

To achieve this automation I have to go through

  1. add choose action
  2. add option action
  3. add condition and set to trigger
  4. add action

then repeat steps 2-4 for each trigger. So for three triggers I reckon that is 14 mouse clicks to get to the point where you can actually setup the actions. This would cut that down to two (or maybe five if the triggered by sections were minimized) to get to the same point

So here is a sample automation I have for my bathroom lights that just sets the brightness on a schedule. This was previously three separate automations but combining them has lots of benefits

  • everything is tired together. With three (or more automations) it is very easy to miss something that is part of set of related automations which can make trying to work out why something has state like it does confusing
  • less automations in the list which makes it less overwhelming and easier to find things
Automation YAML
alias: Bathroom Lights
description: Set brightness based on time
trigger:
  - platform: time
    at: "07:00:00"
    id: morning
  - platform: time
    at: "19:45:00"
    id: evening
  - platform: time
    at: "22:00:00"
    id: night
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - morning
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.bathroom
            data:
              brightness_pct: 100
      - conditions:
          - condition: trigger
            id:
              - evening
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.bathroom
            data:
              brightness_pct: 20
      - conditions:
          - condition: trigger
            id:
              - night
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.bathroom_door
            data: {}
          - service: light.turn_off
            target:
              entity_id: light.bathroom_window
            data: {}
          - service: light.turn_on
            target:
              entity_id: light.bathroom_middle
            data:
              brightness_pct: 1
mode: single

I am saying go thru those 14 mouse clicks to create a blueprint, then use that code to just select the inputs to repeat your actions for the entities. But not saying this wouldn’t work, just saying it’s not there currently.

TBH I don’t understand what you are saying, so some pseudo code, example, flow chart or something might provide a better explanation if you want to get this voted up.

I am obviously not explaining this right as I am struggling to see how blueprints would help improve UX or make things simpler to implement.

What I thinking is that a good number of automations would logically be

switch (trigger):
  case "a": call service X
  case "b": call service Y
  case "c": call service Z

so adding another action
image
which would give you options as

which is essentially a condensed version of doing it through a choose action and manually adding each trigger as a condition


which I had to zoom to about 60% to get it to show on my 1920x1200 monitor

So, put the bathroom lights into a light group and use one action?

The lights are in a group and check the first two triggers, they do call a single action. The specifics of this automation aren’t important, it is just an example. What I am suggesting would still have the same actions, it is the route to how you get to enter those actions I am talking about.

There are three triggers that each require an action. If I was defining how I want the lights to automated in natural language I would say, I want to turn them down to 20% at 19:45,. turn two lights off and one to 1% and turn them up 80% at 07:00.

It could equally be a few cupboards I have where door sensors trigger the lights. I started off with separate on/off automations for each cupboard and then moved towards what I actually want (“the lights to come on when I open the door and off when I close it”). Yes I could use a blueprint for the cupboard and set the door sensor and light as variables but this is way beyond a new user who “just wants the light to come when they open the cupboard”

The current view leads you to create separate automations and has a focus on the coding rather than natural language. They read very much like psuedo code and for a non coder that isn’t as straight forward (even for coders though being able to cut down the amount of clicks is always a bonus)