I would like to be able to template keys instead of only values. For example, in this script where I use a choose
, most options only differ in the keys.
That means that I could rewrite this:
- conditions: # input_boolean.desk_mode changed
condition: template
value_template: "{{ trigger_entity_id == 'input_boolean.{}_{}'.format(name, attribute) }}"
sequence:
service: kef_custom.set_mode
data_template:
entity_id: "{{ 'media_player.{}'.format(name) }}"
desk_mode: "{{ trigger_to_state }}"
- conditions: # input_boolean.wall_mode changed
condition: template
value_template: "{{ trigger_entity_id == 'input_boolean.{}_{}'.format(name, attribute) }}"
sequence:
service: kef_custom.set_mode
data_template:
entity_id: "{{ 'media_player.{}'.format(name) }}"
wall_mode: "{{ trigger_to_state }}"
- conditions: # input_boolean.phase_correction changed
condition: template
value_template: "{{ trigger_entity_id == 'input_boolean.{}_{}'.format(name, attribute) }}"
sequence:
service: kef_custom.set_mode
data_template:
entity_id: "{{ 'media_player.{}'.format(name) }}"
phase_correction: "{{ trigger_to_state }}"
- conditions: # ienput_boolean.high_pass changd
condition: template
value_template: "{{ trigger_entity_id == 'input_boolean.{}_{}'.format(name, attribute) }}"
sequence:
service: kef_custom.set_mode
data_template:
entity_id: "{{ 'media_player.{}'.format(name) }}"
high_pass: "{{ trigger_to_state }}"
into this
- conditions:
condition: template
value_template: "{{ trigger_entity_id == 'input_boolean.{}_{}'.format(name, attribute) }}"
sequence:
service: kef_custom.set_mode
data_template:
entity_id: "{{ 'media_player.{}'.format(name) }}"
"{{ attribute }}": "{{ trigger_to_state }}"