Enable / Disable Several Prefixed Automations At Once

Hi All,

Just curious if somebody knows how to fix the following.

I got a bunch of automations to control well lets say everything around the house.

They are all prefixed for the functional domain they control, for example everything that has to do with the lights the automation starts with: “Lights: Do Something” or with controlling the shutters the automations are prefixed with: “Shutters:”.

I got a vacation automation that depends on a calendar activity, when the vacation starts I shutdown all regular automations and start the vacation automations. In my vacation automation I got a huge list of automations that needs to be shut down when Im away.

The thing is everytime I create a new automation I have to add that automation to the vacation shutdown automation.

It feels like it can be done in a more efficient way.

So I was curious is it possible to shutdown all automations at once that are not prefixed with “Vacation:”?

This way I dont have to manually add newly added automation to the vacation list.

Thanks in advance

The way I do it is with an input select for the occupancy “mode”. It has options like “away”, “home”, “away + guest”, etc…

I include this input select in a condition in the automatons I write.

I change it manually but you could, automate changing the input select with your calendar.

This way you take care of the conditions when you write automations. Much more logical.

Thanks for the reply, this sound really interessing.

Care to share an example of the input select and an simple automation?

You might also want to look at the Presence Simulation integration. It will automatically turn things on and off while you’re away based on how they were ‘x’ days ago. Much easier than creating your own vacation automations.

It’s just a state condition, e.g. only run action if home:

- condition: state
  entity_id: input_select.automation_mode
  state: "Home"

Only run if home or I have a guest staying:

- condition: state
  entity_id: input_select.automation_mode
  state: 
    - "Home"
    - "Guest"
    - "Guest Away"

It’s clear that there are better options that you should pursue instead, but since you asked the question and perhaps the answer could be useful in a different situation:

You can use a template such as this to generate a list of automation entities that don’t begin with “Vacation:”

{{ states.automation 
  | rejectattr('name', 'match', '^Vacation:')
  | map(attribute='entity_id')
  | list }}

And in an automation or script you could call the automation.turn_off service and provide that template as the list of entities.

1 Like

Thanks everybody for the reaction.

Got me a lot of new insights to read in.

@michaelblight, I red about this one but for me it feels a little bit of not being in control of the scenarios.