I have this setup for template switch:
template_light:
friendly_name: Template switch
value_template: "{{ is_state('binary_sensor.template_light_sensor', 'on') }}"
turn_on:
- service_template: >
{% if is_state('switch.template_light', 'off') %}
switch.toggle
{% endif %}
data:
entity_id:
switch.light_switch
turn_off:
- service_template: >
{% if is_state('switch.template_light', 'on') %}
switch.toggle
{% endif %}
data:
entity_id:
switch.light_switch
I have 25 this template switches and it is a pain to change - {% if is_state(‘switch.template_light’, ‘on’) %} for every template switch I have. Is there a way to call the entity_id of this switch like this:
{% if is_state({this.entity_id}, 'on') %}
so I want the {this.entity_id} to return the string - ‘template_light’
Thank you!