Create responsive Master switch

Hi,

I have a master switch for all of my input_boolean.notify_{action} 's:

2 automations for On and Off

Off:

- alias: 'Master - Switch off'
  id: '1511801570100'
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: 'input_boolean.notify_master_switch'
    from: 'on'
    to: 'off'
  condition: []
#    - condition: state
#      entity_id: group.probably_at_home
#      state: 'off'
  action:
    - service: notify.notify
      data_template:
        title: "Master switch"
        message: "{{ trigger.to_state.attributes.friendly_name }} is set to: {{ trigger.to_state.state }}."
    - service: input_boolean.turn_off
      data: 
        entity_id: input_boolean.notify_motion
    - service: input_boolean.turn_off
      data: 
        entity_id: input_boolean.notify_mode_selection
    - service: input_boolean.turn_off
      data: 
        entity_id: input_boolean.notify_activity_selection

same for On.

i have 2 questions to make it more robust, and flexible.

  • Could i make the above 2 automations into 1, with a template sensing the On and Off state?
  • For now, this is a one way automation. switching the master switch, switches all the others. But if one of the underlying booleans is flipped, the master switch doesn’t go along. It must be made responsive to the underlying booleans. How could i do that, without having to specify all booleans.

My wish is to add several more, (all following the naming principle of input_boolean.notify_{action} and it would be very handy if this Master switch could be made in a way it reads that pattern., instead of having to explicitly name all booleans. Taking new booleans into account automatically. Or causing no issues when deleting or changing existing ones.

Hope this makes sense… Please shine your templating magic on this

Cheers,
Marius

My approach to this would have been to use a template switch called master switch with its value template based on the group.input_boolean (made up off all your input boolean) and the turn on / off commands change the group or individual input boolean.

"For now, this is a one way automation. switching the master switch, switches all the others. But if one of the underlying booleans is flipped, the master switch doesn’t go along. It must be made responsive to the underlying booleans. How could i do that, without having to specify all booleans."

Presumably this means “if all the booleans are switched off individually, the master needs to be switched off”?

As @RobDYI says, groups is the way forward, but you don’t need a template switch, just use the group itself as a toggle switch on the interface.

1 Like

thanks to the both of you!
Thought about the Group strategy, and use it in fact already.
Its just that i would have wanted it to be ordered along the templated way too.

So i guess will need to follow both strategies :slight_smile:

@RobDYI
i use template switches a lot, but more to combine different platforms than to use a template in this sense here. What would be the setup for my booleans? iow, what would the template look like i the case of input_boolean.notify_{template_here}?

Thanks,
Marius