How to pause automations in holidays

I have 100 automations, 70 are active and 30 are inactive.
We are away for a few weeks and I want t pause all automations and when I’m back home, I want to reactivate the 70 automations, but of course not the 30 which are inactive.

If none of the 100 automations should execute then the quickest way is to turn off the server.

Otherwise, you can add a condition, to each one of the 70 automations, that checks the state of a “Holiday” input_boolean (i.e. automation will not execute its action if the input_boolean is on).

Alternatively, create a script to turn off 70 automations.

It’s always a good thing to have a boolean or presence sensor included in the automations in case you are not home.

Not at home is something different than 6 weeks away.

Depends on how you have set up your automations.
I wouldn’t change anything on my automations for six weeks, but I can understand that someone might want to.

In my setup I use an input select to choose the different modes for my house. Home, Night, Guest, Away, and Vacation. I use the state of that input select as a trigger and/or condition in any automation that should or should not run in the various modes.

BTW the state of that input select is normally automatically selected by presence entities the house alarm. I rarely have to touch it. Leaving your smart home for a vacation shouldn’t be more work than leaving a dumb house for a vacation!

    - platform: state
      entity_id: input_select.occupancy_mode
      to:
        - Away
        - Vacation
    - condition: state
      entity_id: input_select.occupancy_mode
      state:
        - Away
        - Vacation

Yes this is the ideal situation, but it is also a lot of work.

But you only need to do it once. The sooner you add this the easier it will be.

Whether you use an input_boolean or an input_select, the principle remains the same: there must be a common entity in all your automations. There’s no magical way to add it without editing each automation.

If it seems like too much work, you have the other options I mentioned: create a script to turn off the 70 automations or just turn off the server.

I would prefer a HA setting to switch off pause all automations with one setting.

script:
  automations_off:
    alias: Automations Off
    description: Turn off all automations.
    mode: single
    sequence:
      - service: automation.turn_off
        entity_id: all

Here ya go. Put it in your config, reload your scripts, then run it from the Scripts configuration menu.

1 Like

The OP has 100 automations and wants to disable/re-enable just 70 of them (the others are already disabled). An ‘All Automation Off’ script overlooks the task of how 70 of the 100 automations will be re-enabled.

The script needs to include a list of the automations to be disabled (as opposed to disabling all of them). That’s probably still ‘more work’ than the OP appears to be willing to invest.

I was responding to this notion.

I would prefer a HA setting to switch off all automations with one setting.

He doesn’t seem to want to put that much effort into accomplishing this. You of course are absolutely correct pointing out that he needs to differentiate the automations he wants to turn off and on from the other 30. Either he does it here in the script that he then must update every time he adds a new automation, or of course preferably with conditions in the automations themselves as they are created.

Edit. He could also add intital: true to all the automations he wants to restart when he gets home, use the script above to turn them all off, then just restart HA when he returns home. Bunch of ways to skin this cat, some better than others :upside_down_face:

I tried to read cores.restore_state with a python program and find what automations are on and which are off. This seems to work.

FWIW, a template can be used to turn off only the automations that are currently on.

{{ states.automation | selectattr('state', 'eq', 'on')
    | map(attribute='entity_id') | join(', ') }}

However, neither a template or python_script will be helpful when it comes time to turn on only 70 of the 100 automations.


EDIT

Paste this into the Template Editor:

{{ states.automation | selectattr('state', 'eq', 'on')
| map(attribute='entity_id') | join('\n - ') }}

Screenshot:

You can copy-paste the result into a script (tweak the first line) that turns them on/off.

#script:
  automations_on_off:
    alias: Automations On Off
    description: Turn on or off specific automations.
    sequence:
      - service: automation.turn_{{ mode }}
        entity_id: 
          - automation.bathroom_motion_lights_time_aware
          - automation.general_low_battery_alert
          - automation.motion_activated_light_time_constraints_test
          - automation.test_99
          - automation.test_now
          - automation.zigbee2mqtt_ikea_on_off_button_with_dimmer_2

Call it like this:

    service: script.automations_on_off
    data:
      mode: 'on'
1 Like

Wow, this is really great, that will do it! Thanks a lot!

1 Like