I have a lot of automations. Is there any easy solution to toggle a bunch of them with one button?
Not sure what you mean ‘toggle’. Do you mean to enable them? If so, you can use a service:
service: automation.turn_off
data: {}
target:
entity_id:
- automation.androidtv_scans
- automation.androidtv_scans1
service: automation.turn_on
data: {}
target:
entity_id:
- automation.androidtv_scans
- automation.androidtv_scans1
But you really shouldn’t be enabling/disabling automations as part of your coding. You should use helpers to determine what to run and when…
There’s a request for this to be leveraged with the groups functionality.
There’s no kill switch like in webcore where you can disable them all at once. You would have to build the switch to do it for you.
I’ve had to spend WAY too much time doing this the hard way by leveraging input booleans to control my automations. Sometimes I just want to turn off all automations for one room (I don’t want anything to change) and sometimes I want to kill the majority of automations like when the house cleaners come. You can simplify this way down for your needs but it will show you how to do it:
alias: Automation Controls
description: ''
trigger:
- platform: state
entity_id:
- input_boolean.bedroom_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.bedroom_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.bedroom_2_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.bedroom_2_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.office_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.office_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.stairway_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.stairway_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.laundry_room_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.laundry_room_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.living_room_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.living_room_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.kitchen_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.kitchen_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.Dining_room_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.Dining_room_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.media_room_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.media_room_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.2nd_floor_bathroom_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.2nd_floor_bathroom_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.downstairs_bathroom_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.downstairs_bathroom_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.front_entryway_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.front_entryway_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.garage_entryway_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.garage_entryway_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.den_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.den_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.garage_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.garage_automations
to: 'on'
- platform: state
entity_id:
- input_boolean.ring_announcements
to: 'off'
- platform: state
entity_id:
- input_boolean.ring_announcements
to: 'on'
- platform: state
entity_id:
- input_boolean.all_automations
to: 'off'
- platform: state
entity_id:
- input_boolean.all_automations
to: 'on'
condition: []
action:
- if:
- condition: state
entity_id: input_boolean.bedroom_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id:
- automation.bedroom_1_accent_lights_auto_on
- automation.office_accent_lights_auto_on
- automation.bathroom_1_auto_on
- automation.office_curtains_auto_open
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.adaptive_lighting_bedroom_accent_lights
- switch.adaptive_lighting_bedroom_house_lights
- service: script.set_bedroom_air_filters_to_five
data: {}
else: []
- if:
- condition: state
entity_id: input_boolean.bedroom_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id:
- automation.bedroom_1_accent_lights_auto_on
- automation.bathroom_1_auto_on
- automation.office_accent_lights_auto_on
- automation.office_curtains_auto_open
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.nap_time
- condition: time
before: '21:45:00'
after: '08:00:00'
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.adaptive_lighting_bedroom_accent_lights
- switch.adaptive_lighting_bedroom_house_lights
- service: media_player.media_pause
data: {}
target:
device_id:
- 2e67175ce4168783cc63481dd66a25a6
- 782214079897c40cfc06c457b559de46
- service: script.set_office_air_filter_to_auto_2
data: {}
else: []
- if:
- condition: state
entity_id: input_boolean.bedroom_2_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id:
- automation.bedroom_2_accent_lights_auto_on
- automation.bathroom_2_accent_lights_auto_on
- condition: time
before: '21:45:00'
after: '08:00:00'
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.adaptive_lighting_bedroom_2_accent_lights
- switch.adaptive_lighting_bedroom_2_house_lights
else: []
- if:
- condition: state
entity_id: input_boolean.bedroom_2_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id:
- automation.bedroom_2_accent_lights_auto_on
- automation.bathroom_2_accent_lights_auto_on
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.adaptive_lighting_bedroom_2_accent_lights
- switch.adaptive_lighting_bedroom_2_house_lights
else: []
- if:
- condition: state
entity_id: input_boolean.laundry_room_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id: automation.laundry_room_auto_on
- if:
- condition: state
entity_id: input_boolean.laundry_room_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id: automation.laundry_room_auto_on
- if:
- condition: state
entity_id: input_boolean.stairway_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id: automation.stairway_lights_auto_on_off
- if:
- condition: state
entity_id: input_boolean.stairway_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id: automation.stairway_lights_auto_on_off
- if:
- condition: state
entity_id: input_boolean.office_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id: automation.office_accent_lights_auto_on
- if:
- condition: state
entity_id: input_boolean.office_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id: automation.office_accent_lights_auto_on
- if:
- condition: state
entity_id: input_boolean.living_room_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id: automation.living_room_accent_lights_auto_on_2
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.adaptive_lighting_living_room_house_lights
- switch.adaptive_lighting_living_room_accent_lights
- if:
- condition: state
entity_id: input_boolean.living_room_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id: automation.living_room_accent_lights_auto_on_2
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.adaptive_lighting_living_room_house_lights
- switch.adaptive_lighting_living_room_accent_lights
- if:
- condition: state
entity_id: input_boolean.media_room_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id: automation.media_room_accent_lights_auto_on
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.adaptive_lighting_media_room_house_lights
- switch.adaptive_lighting_media_room_accent_lights
- if:
- condition: state
entity_id: input_boolean.media_room_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id: automation.media_room_accent_lights_auto_on
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.adaptive_lighting_media_room_house_lights
- switch.adaptive_lighting_media_room_accent_lights
- if:
- condition: state
entity_id: input_boolean.dining_room_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id: automation.dining_room_accent_lights_auto_on
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.adaptive_lighting_dining_room_accent_lights
- switch.adaptive_lighting_dining_room_house_lights
- if:
- condition: state
entity_id: input_boolean.dining_room_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id: automation.dining_room_accent_lights_auto_on
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.adaptive_lighting_dining_room_house_lights
- switch.adaptive_lighting_dining_room_accent_lights
- if:
- condition: state
entity_id: input_boolean.kitchen_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id: automation.kitchen_accent_lamps_auto_on
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.adaptive_lighting_kitchen_accent_lights
- switch.adaptive_lighting_kitchen_house_lights
- if:
- condition: state
entity_id: input_boolean.kitchen_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id: automation.kitchen_accent_lamps_auto_on
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.adaptive_lighting_kitchen_house_lights
- switch.adaptive_lighting_kitchen_accent_lights
- if:
- condition: state
entity_id: input_boolean.front_entryway_automations
state: 'off'
then:
- service: automation.turn_off
data: {}
target:
entity_id: automation.front_entryway_accent_lights_auto_on
- if:
- condition: state
entity_id: input_boolean.front_entryway_automations
state: 'on'
then:
- service: automation.turn_on
data: {}
target:
entity_id: automation.front_entryway_accent_lights_auto_on
mode: parallel
max: 20
Every time one of my automation booleans changes to off or on, it will decide which automations to turn off. Another benefit is I can give a verbal command to Alexa to ‘turn off living room automations’ and before I can set foot into the room, it will turn them off to where they won’t fire (instant).
This also has my adaptive lighting turn on/offs connected but you can easily strip that out. That just ensures that adaptive lighting stops running when i tell the automations to be off and conversely when automations turn back on, to turn the adaptive lighting.
There is another popular school of thought that say you should not be turning automations on or off but controlling them with conditions instead.
That long, repetitive automation can be eliminated if you simply add a State Condition to each one of your automations. The condition simply checks if the associated input_boolean is on
. If it’s off
, the automation doesn’t execute its action
.
That’s the more “automated” way of ensuring an automation performs work only under the correct conditions. After all, that’s the purpose of an automation’s condition
.
Exactly what the two above me said. I have a ‘house keeper’ toggle that flips when their phone connects to my guest wifi. I have conditions in many of my automations to prevent them from running when they are there. I do the same with ‘company’ and google tts. You really should not be relying on disabling automations as part of a ‘normal’ working condition. I’ll disable an automation as a ‘temporary’ thing if needed but typically if I have to disable something, then later on i’ll build a condition into it so it will be programmatic the next time.
This. Instead of over-engineering a solution, choose the most logical path, and in this case it is that all automations are dependent on the value of a helper.
I’ve been doing this from day one, I have all sorts of stuff that only runs if no guests are staying over, or only if we are awake or if the A/C is on, etc - all based on this premise.
I came from webcore in Jan and now that you’ve pointed it out, I don’t even know why I did it that way.
I changed it to this:
trigger:
- platform: state
entity_id:
- input_boolean.bedroom_automations
- input_boolean.living_room_automations
- input_boolean.bedroom_2_automations
- input_boolean.media_room_automations
- input_boolean.kitchen_automations
- input_boolean.dining_room_automations
- input_boolean.downstairs_bathroom_automations
- input_boolean.front_entryway_automations
- input_boolean.garage_entryway_automations
- input_boolean.garage_automations
- input_boolean.laundry_room_automations
- input_boolean.stairway_automations
- input_boolean.2nd_floor_bathroom_automations
- input_boolean.all_automations
- input_boolean.office_automations
- input_boolean.den_automations
- input_boolean.ring_announcements
Thanks
Not quite sure what you thought I had pointed out but it wasn’t what you changed it to.
Scenes are a simple and integrated solution. No need for input_booleans
i.e.
- Create a Scene,
- Add your Automations in Entities
- Click on each one to set the desired state, On/Off, HA will temporarily execute the change for now,
- save the Scene.
The change in status to your automations will be reverted to the previous one upon saving.
However, if you create 2 scenes, 1 for Disable, 1 for Enable, you still have to maintain both if you add or remove an automation from the list. That is also where grouping automations would be helpful.
I believe it’s currently possible to create a traditional group
containing automation
entities. The resulting group
entity can be turned on/off (no need to maintain two separate scenes).
Yes, thanks, that works !
That even does not need any Scene.
And a simple lovelace button can switch the group off/on (which will disable/enable the automations from the Group).
A few cons however :
- Needs a manual configuration in groups.yaml, and cannot be configured in the UI.
- This is “not recommended”,
- The correctly created entity will not be listed in the Helpers UI
Well, I’ll live with this
-
It’s a ‘con’ only if one is fixated on using the UI only. If you do that, you will cut yourself off from a vast array of Home Assistant’s features because not everything is available in the UI.
-
It’s ‘not recommended’ to use a traditional group if there’s an equivalent ‘group helper’. In this case, there’s no ‘group helper’ for automations. In addition, if you wanted to create a group containing different kinds of entities, there’s no group helper for that either.
-
It won’t be listed there because it’s a
group
entity. You may have noticed that ‘group helpers’ are notgroup
entities.
-
Well, I do want to keep things as simple as possible and as maintainable as possible because this system is so complex that I have spent way too much time trying to understand all these things, reading and watching tutorials, fixing “syntax errors” in yaml and in templates, installing updates daily… However I do understand your point, and other home automations systems have probably the same complexity. I chose Home Assistant only because it is the only one that can manage my covers’ brand.
-
The ‘not recommended’ point is not as clear in the documentation. However, what I understood from the documentation, is that this is very far from becoming ‘not supported’
-
Yes, and that is also painful, having groups as Groups, and having switch group from helpers as Switchs. Even if the behaviour is not exactly the same
Thanks for clarifying anyway.
It remains supported, just like Template Sensors in legacy format remain supported.
The so-called Group Helpers don’t create group
entities. The entity produced is the same domain as its members. If the members are lights, the grouped entity is also a light
.
In other words, you can’t use a Group Helper to combine entities from different domains (such as a combination of binary_sensor
and switch
entities). However you can do that with a traditional group
(so it continues to be useful).
Even easier: create an Entities card with the automations
You can then selectively or globally switch them off.