Skip to content

Instantly share code, notes, and snippets.

@Blackshome
Last active October 4, 2025 12:17
Show Gist options
  • Select an option

  • Save Blackshome/dbcd8ebfdd0350144fc1503fc0fa8112 to your computer and use it in GitHub Desktop.

Select an option

Save Blackshome/dbcd8ebfdd0350144fc1503fc0fa8112 to your computer and use it in GitHub Desktop.
switch-turn-on-off-entities.yaml
blueprint:
name: Switch - Turn ON & OFF Entities
description: >
# πŸ”› Switch - Turn ON & OFF Entities
**Version: 1.4**
πŸ”€ One switch to rule them all - synchronize your entities effortlessly!
**If you like my blueprints, and would like to show your support or just say thank you?** [Click Here](https://www.paypal.com/donate/?hosted_button_id=WAZS3QSDTPGA8) πŸ™‚
<details>
<summary><b>The Automation Process:</b> πŸ‘ˆ</summary>
- When you turn any switch ON it will turn ON the main entity input.
- When you turn all the switches OFF it will turn OFF the main entity input.
- You have the option to input an alternating entity that will be the opposite state to the main entity.
**NOTE** - The switch can be any entity with an ON & OFF state.
</details>
Need help?
- FAQ: [Click Here](https://community.home-assistant.io/t/481546/2)
- Community Support Including Updates: [Click Here](https://community.home-assistant.io/t/481546)
Required = *
domain: automation
input:
switch:
name: Switch *
description: >
The switch that controls the main and alternating entities.
selector:
entity:
multiple: true
main_entity:
name: Main Entity *
description: >
The main entity that will turn ON when the switch is ON, and OFF when the switch is OFF.
selector:
entity:
multiple: true
alternating_entity:
name: Alternating Entity (optional)
description: >
The entity that will always be the opposite state of the main entity.
default: []
selector:
entity:
multiple: true
variables:
switch: !input switch
main_entity: !input main_entity
alternating_entity: !input alternating_entity
triggers:
- trigger: state
entity_id: !input switch
from: "off"
to: "on"
- trigger: state
entity_id: !input switch
from: "on"
to: "off"
for:
milliseconds: 200
actions:
- choose:
- alias: "Check if any alternating entity are enter in"
conditions:
- "{{ alternating_entity == [] }}"
sequence:
- choose:
- alias: "Check if switch is on"
conditions:
- condition: state
entity_id: !input switch
state: 'on'
match: any
sequence:
- alias: "Turn ON the main entities"
action: homeassistant.turn_on
target:
entity_id: !input main_entity
- alias: "Check if switch is off"
conditions:
- condition: state
entity_id: !input switch
state: 'off'
sequence:
- alias: "Turn OFF the main entities"
action: homeassistant.turn_off
target:
entity_id: !input main_entity
default:
- choose:
- alias: "Check if switch is on"
conditions:
- condition: state
entity_id: !input switch
state: 'on'
match: any
sequence:
- alias: "Turn ON the main entities"
action: homeassistant.turn_on
target:
entity_id: !input main_entity
- alias: "Turn OFF the alternating entity entities"
action: homeassistant.turn_off
target:
entity_id: !input alternating_entity
- alias: "Check if switch is off"
conditions:
- condition: state
entity_id: !input switch
state: 'off'
sequence:
- alias: "Turn OFF the main entities"
action: homeassistant.turn_off
target:
entity_id: !input main_entity
- alias: "Turn ON the alternating entity entities"
action: homeassistant.turn_on
target:
entity_id: !input alternating_entity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment