Grouped switch

I have a bunch of KNX switches which I would like to group into one (visible) switch. Is there a way to achieve it?

Yep here is an example of the default view with many groups.

Thanks, I’m aware of the groups (and views). What I’m trying to achieve is a combined (single) switch that would toggle several other (hidden) switches and correctly update it’s status (on/off).

A script should do that.

Well, you might want to create either a script or scene to turn them all on, and another to turn them all off, then create an input_boolean and an automation with a data template:

configuration.yaml example:

input_boolean:
  my_multi_switch:
    name: My Multi Switch
    initial: off
    icon: mdi:bookmark

automation:
  trigger:
    platform: state
    entity_id: input_boolean.my_multi_switch
  action:
    service: scene.turn_on
    data_template:
      entity_id: >
        {% if trigger.to_state.state == "on" %}
          scene.my_switches_on
        {% else %}
          scene.my_switches_off
        {% endif %}
1 Like

Thanks! I’ll give it a shot!

(for completeness) could you share how the scene part would look like? thks

Just for those who find this thread and are looking for an answer, you don’t need to do anything with an automation.

First, define a switch template that turns on and off both switches:

- platform: template
  switches:
    grow_lights:
      friendly_name: "Grow Lights"
      value_template: "{{ is_state('sensor.grow_light_combined_state', 'on') }}"
      turn_on:
        service: switch.turn_on
        entity_id: 
          - switch.grow_lights_1_15
          - switch.grow_lights_2_13
      turn_off:
        service: switch.turn_off
        entity_id:
          - switch.grow_lights_1_15
          - switch.grow_lights_2_13

Next, define a sensor that combines the state of both switches into a single sensor using a sensor template:

- platform: template
  sensors:
    grow_light_combined_state:
      value_template: '{{ "on" if (is_state("switch.grow_lights_1_15", "on") and is_state("switch.grow_lights_2_13", "on")) else "off" }}'
      friendly_name: "Grow Lights Combined"

Finally, you can hide the original switches:

switch.grow_lights_1_15:
  hidden: true
switch.grow_lights_2_13:
  hidden: true
1 Like

Thanks, I actually did it exactly like this!

I did try this example but got an error:
2017-09-29 10:55:14 ERROR (MainThread) [homeassistant.config] Invalid config for [switch.template]: [TV_kijken] is an invalid option for [switch.template]. Check: switch.template->switches->TV_kijken. (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch.template/
2017-09-29 10:55:14 ERROR (MainThread) [homeassistant.config] Invalid config for [switch.template]: required key not provided @ data[‘switches’]. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/switch.template/

What am I doing wrong? In my “configuration.yaml” file I put this:
switch:

  • platform: template
    switches:
    TV_kijken:
    friendly_name: “TV kijken”
    value_template: “{{ is_state(‘TV_Setopbox_geluid_gecombineerd_status’, ‘on’) }}”
    turn_on:
    service: switch.turn_on
    entity_id:
    - switch.greenwave_powernode_6_port_switch
    - switch.greenwave_powernode_6_port_switch_2
    - switch.greenwave_powernode_6_port_switch_4
    turn_off:
    service: switch.turn_off
    entity_id:
    - switch.greenwave_powernode_6_port_switch
    - switch.greenwave_powernode_6_port_switch_2
    - switch.greenwave_powernode_6_port_switch_4
  • platform: template
    sensors:
    TV_Setopbox_geluid_gecombineerd_status:
    value_template: ‘{{ “on” if (is_state(“switch.greenwave_powernode_6_port_switch”, “on”) and is_state(“switch.greenwave_powernode_6_port_switch_2”, “on”) and is_state(“switch.greenwave_powernode_6_port_switch_3”, “on”)) else “off” }}’
    friendly_name: “TV kijken gecombineerd”