Multiple Automations for One Device

Is it possible to set multiple different event automations for one device under one automation or do I need to create a new automation for each individual event?
For example; I have a Tapo smart plug powering my pond waterfall.

I want to set the following actions for it:

  • turn off when battery drops below 15%
  • turn back on when battery rises above 15%
  • turn off when solar production reaches 0
  • turn back on when solar production above 3kw
  • turn off when battery off grid
  • turn back on when battery back on grid

I have a few different devices I want to do this with and if I need to create a separate automation for each individual event I’ll have an automation list a mile long.
Is there a simpler way?

Yes it is possible to have multiple triggers in one automation.

One common method is assigning IDs for each trigger then using those in a Trigger condition in a Choose or If/Then action.

It depends on your approach to maintenance. In six months time, an automation list “a mile long” may be easier to troubleshoot than a smaller number of automations with multiple triggers, particularly if you name and label them effectively and use description fields to describe how they fit together.

It’s a matter of personal preference - documentation is a pain, but later on you may be glad you took the trouble. Starting documentation when you already have a complex system is a monumental task. I don’t think it makes much difference to HA.

I tend to think that it’s easier to troubleshoot when everything is in a single place, because six months down the line it’s difficult to remember all the interconnections.

This is an example I use to control bathroom light status with the use of ids:

alias: Outside Lux
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.weatherstation_solar_lux
    below: 8000
    id: dark_outside
  - trigger: numeric_state
    entity_id:
      - sensor.weatherstation_solar_lux
    id: light_outside
    above: 7999
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - dark_outside
        sequence:
          - action: input_boolean.turn_off
            target:
              entity_id: input_boolean.bathroom_lights_automation
      - conditions:
          - condition: trigger
            id:
              - light_outside
        sequence:
          - action: input_boolean.turn_on
            target:
              entity_id: input_boolean.bathroom_lights_automation
mode: single

In addition to what’s been written so far, I think it’s important to consider not just the triggers for the automations as you wrote them down in you bullet point list above, but also the conditions under which these triggered will result into an action, e.g.

  • Do you want to turn on the switch always when the battery rises above 15%
    or
    Only when it rises above 15% (trigger) AND the ‘solar production is above 3kW’ (condition)
  • Do you want to always turn on the switch when the solar production rises above 3kW (trigger)
    or
    Only when ‘solar production rises above 3kW’ while the battery is above 15%’ (condition)

You will notice that I slightly rephrased your items - that’s been done to make it clearer that the triggers are fired by a ‘change in state’ while the conditions check if ‘a state already fulfills a requirement at the point in time the trigger is activated’.

I personally like to keep triggers and actions for a switch in the same automation (separating them by using Trigger IDs) as long as they fulfill a common purpose.

1 Like

That is a very good point and yes I will review my intended triggers as you make a good point. It will be when battery above 15% AND pv above 3kw.

I will do more reading on assigning IDs as that appears to be the way to go.

Just thought there may have been a way in the automations page to group automations under each device rather than a thousand automations for every device in one list.

Time for more reding and learning.

Thanks all!

So, in this case, you’ll need to have both items as triggers and conditions, because:

  • If the battery goes above 15% (trigger) you want PV to already be above 3kW (condition) to turn the switch on
    and
  • If PV goes above 3kW (trigger) you want the battery to already be above 15% (condition) to turn on the switch

The ‘tricky bit’ about grouping automations under each device comes up when you have to actually do it, i.e.

  • Do you group by the device that is used for a trigger?
    You might use multiple devices for triggers to, e.g. turn on a light: a button, a motion detector, time
  • Do you group by the device that is required to fulfill a condition?
    Conditions from different devices might need to be fulfilled to, e.g. turn on a light: is the sun above or below the horizon, is somebody’s mobile phone home, time
  • Do you group by the device that carries out an action?
    Actions might be carried out for multiple devices, e.g. a smart switch can turn on a light, a smart light bulb can change colors, a dashboard can announce that an outside light has been turned on

I use labels to that describe a purpose to ‘group’ these items, e.g. ‘Notify Mobile’, ‘Write to File’, ‘Initiate Voice Satellite Question’.
The advantage of labels is, that you can assign more than one label to an automation or script if multiple actions are carried out, e.g. ‘Notify Mobile’ and ‘Write to File’