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 %}
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
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â