Anybody could tell me what’s wrong here with this sensor template? I’m getting a syntax error…
- platform: template
sensors:
lock_last_state:
friendly_name: Dernière activité sur le lock
entity_id:
- sensor.lock_status
value_template: >-
{% if is_state('sensor.lock_status', 'Locked by RF') %}
Verrouillé par Z-Wave
{% if is_state('sensor.lock_status', 'Unlocked by RF') %}
Déverrouillé par Z-Wave
{% if is_state('sensor.lock_status', 'Locked with Keypad by user 1') %}
Verrouillé par Sylvain
{% if is_state('sensor.lock_status', 'Unlocked with Keypad by user 1') %}
Déverrouillé par Sylvain
{% if is_state('sensor.lock_status', 'Locked with Keypad by user 2') %}
Verrouillé par Josée
{% if is_state('sensor.lock_status', 'Unlocked with Keypad by user 2') %}
Déverrouillé par Josée
{% if is_state('sensor.lock_status', 'Locked with Keypad by user 3') %}
Verrouillé par invité
{% if is_state('sensor.lock_status', 'Unlocked with Keypad by user 3') %}
Déverrouillé par invité
{% else %}
NA
{% endif %}
Error:
Configuration invalid
Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: Unexpected end of template. Jinja was looking for the following tags: ‘elif’ or ‘else’ or ‘endif’. The innermost block that needs to be closed is ‘if’.) for dictionary value @ data[‘sensors’][‘lock_last_state’][‘value_template’]. Got "{% if is_state(‘sensor.lock_status’, ‘Locked by RF’) %}\n Verrouillé par Z-Wave\n{% if is_state(‘sensor.lock_status’, ‘Unlocked by RF’) %}\n Déverrouillé par Z-Wave \n{% if is_state(‘sensor.lock_status’, ‘Locked with Keypad by user 1’) %}\n Verrouillé par Sylvain \n{% if is_state(‘sensor.lock_status’, ‘Unlocked with Keypad by user 1’) %}\n Déverrouillé par Sylvain \n{% if is_state(‘sensor.lock_status’, ‘Locked with Keypad by user 2’) %}\n Verrouillé par Josée \n{% if is_… (See ?, line ?). Please check the docs at Template - Home Assistant