Skip to content

Instantly share code, notes, and snippets.

@Didgeridrew
Last active February 26, 2024 17:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Didgeridrew/03dbb43963000ce222b9194f382e45c0 to your computer and use it in GitHub Desktop.
Save Didgeridrew/03dbb43963000ce222b9194f382e45c0 to your computer and use it in GitHub Desktop.
Entrained Input_Booleans
### You can list the booleans in the template to make setup a little easier.
alias: Entrained Booleans (only 1 on at a time)
description: ''
trigger:
- platform: state
entity_id:
- input_boolean.test_bool_1
- input_boolean.test_bool_2
- input_boolean.test_bool_3
to: 'on'
condition: []
action:
- service: input_boolean.turn_off
target:
entity_id: '{{ inactive_bools }}'
variables:
inactive_bools: >-
{{ expand('input_boolean.test_bool_1', 'input_boolean.test_bool_2', 'input_boolean.test_bool_3')
| rejectattr('entity_id', 'eq', trigger.to_state.entity_id)
| map(attribute='entity_id') | list -}}
mode: single
### Or you can also put the booleans into a group to make the template a little easier to read.
alias: Entrained Booleans (only 1 on at a time)
description: ''
trigger:
- platform: state
entity_id:
- input_boolean.test_bool_1
- input_boolean.test_bool_2
- input_boolean.test_bool_3
to: 'on'
condition: []
action:
- service: input_boolean.turn_off
target:
entity_id: '{{ inactive_bools }}'
variables:
inactive_bools: >-
{{ expand(states.group.test_bools)
| rejectattr('entity_id', 'eq', trigger.to_state.entity_id)
| map(attribute='entity_id') | list -}}
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment