Skip to content

Instantly share code, notes, and snippets.

@daredoes
Created December 7, 2022 17:54
Show Gist options
  • Select an option

  • Save daredoes/26108f1985f33b59d03c8c64be8e6f21 to your computer and use it in GitHub Desktop.

Select an option

Save daredoes/26108f1985f33b59d03c8c64be8e6f21 to your computer and use it in GitHub Desktop.
A HASSIO Blueprint
blueprint:
name: Selects Follows Select
description: Have a set of selects follow another select, and optionally have a scene named `scene.{leader_id}_{option} activated.
domain: automation
input:
select_parent:
name: Leader
selector:
entity:
domain:
- "input_select"
- "select"
select_children:
name: Followers
default: {}
selector:
target:
entity:
domain: select
input_select_children:
name: Input Select Followers
default: {}
selector:
target:
entity:
domain: input_select
scene_follow:
name: Have Scene Follow
selector:
boolean:
reset_mode:
name: Reset Mode Name
description: Enter a mode name here, and the input select will reset itself back to this mode after selecting a new mode, without having anything follow it.
default:
selector:
text:
trigger:
platform: state
entity_id: !input select_parent
mode: parallel
variables:
select_children: !input select_children
input_select_children: !input input_select_children
select_parent: !input select_parent
option: "{{ trigger.to_state.state }}"
scene_follow: !input scene_follow
reset_mode: !input reset_mode
action:
- if:
- condition: template
value_template: "{{ this.state != reset_mode }}"
then:
- parallel:
- if:
- condition: template
value_template: "{{ scene_follow }}"
then:
- service: scene.turn_on
data: {}
target:
entity_id: "{{ select_parent|replace('input_select.', 'scene.') }}_{{ option|lower|replace(' ', '_') }}"
- if:
- condition: template
value_template: "{{ input_select_children != {} }}"
then:
- service: input_select.select_option
data:
option: "{{ option }}"
target: !input input_select_children
- if:
- condition: template
value_template: "{{ select_children != {} }}"
then:
- service: select.select_option
data:
option: "{{ option }}"
target: !input select_children
- if:
- condition: template
value_template: "{{ reset_mode != '' }}"
then:
- if:
- condition: template
value_template: "{{ 'input_select.' in select_parent }}"
then:
- service: input_select.select_option
data:
option: "{{ reset_mode }}"
entity_id: "{{ select_parent }}"
else:
- service: select.select_option
data:
option: "{{ reset_mode }}"
entity_id: "{{ select_parent }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment