Switch that turns on/off multiple devices regardless of device state

TL/DR: I want a switch that does “turn off all devices, no matter what state they are in or who turned them on” and vice versa

This is a question that most likely has been answered many times over, and i derived my current work in progress with those two helpful threads. The idea is a template switch that flips an input_boolean that is tied to an automation that in turn fires a script for on and one for off. The whole thing works if i use itself (and thus flip the input_boolean) to switch on or off. This way the template switch has its defined state and everyone is happy. But it doesn’t work for when all or single lights or devices were switched on independently (not flipping the input_boolean). My problem (and this is where my logic/understanding gets murky) is that i’m pretty sure the template switch is the wrong tool, since i need a state to work with. But what else then? Add a input_boolean flip to every single device? The reason i need it to be a switch is for hue_emulation/alexa. I have a similar thing with a button on lovelace, but there i can just use call service and run a script (button card).

tap_action:
  action: call-service
  service: switch.turn_on

Anyway here is my code so far:

input_boolean:
  master_switch_input_bool:
    name: Master switch input boolean
    initial: off
switch:
  - platform: template
    switches:
      alles:
        value_template: '{{ states("input_boolean.master_switch_input_bool") }}'
        friendly_name: 'Everything'
        turn_on:
          - service: input_boolean.turn_on
            entity_id: input_boolean.master_switch_input_bool
        turn_off:
          - service: input_boolean.turn_off
            entity_id: input_boolean.master_switch_input_bool
automation (created with the gui):
- id: '1578416796397'
  alias: Bool Turn Lights on
  description: ''
  trigger:
  - entity_id: input_boolean.master_switch_input_bool
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data: {}
    entity_id: script.1578416156582
    service: script.turn_on
- id: '1578416881785'
  alias: Bool Turn Lights off
  description: ''
  trigger:
  - entity_id: input_boolean.master_switch_input_bool
    from: 'on'
    platform: state
    to: 'off'
  condition: []
  action:
  - entity_id: script.1578416094874
    service: script.turn_on

I would create a group with this devices.
Then you can turn on/off this group.

Thank you, but I tried groups, but that works only for one side of the equation. If i set “all” to “false” the group is on when at least one entity of the group is on. No way for me to switch the rest on. If i set it to “true” its inverted and no way to switch them off. Or did i miss anything?

You can set all: true
See here:


Is this what you want?

That’s what i described. When it is true any one device is enough to set the group as on, when it is false any one device that is off sets the group off. That means i can’t use the switch to set the group any more “on” that it already is, which is to say switch the remaining entities on. Vice versa for off/false setting.

Under configuration / customise select your switch and set assumed _state to true.
Your slider will turn in to two buttons.
On and Off.

Thanks, but i think you misunderstood me. The two buttons wouldn’t help me getting rid of the issue that it is a group of devices in unknown states.

Did anyone find a solution to this? I am having the same issue and cant find a solution!

OK, another one on the hunt for the elusive group control. I’m thinking the workaround is two different scenes, which I hate.