Call-service > if statement not working

Not sure what to do here.

The error message replaces the ‘.’ between “lock.unlock” with a slash.

double_tap_action:
  action: call-service
  service: |-
    {% if is_state('lock.front_door_lock','locked') %}
      lock.unlock
    {% else %}
      lock.lock
    {% endif %}  
  target:
    device_id: 192b5263584bbe96bb3a26246f796922
  data: {}

You can’t use templates in dashboard cards. Put your action in a script (that does support templates) and call that from the double tap action. Scripts are services.

Also use the entity id instead of the device id in your script. It will save you pain in future.

double_tap_action:
  action: call-service
  service: script.toggle_lock
script:
  toggle_lock:
    - sequence:
        - service: >
            {% if is_state('lock.front_door_lock','locked') %}
              lock.unlock
            {% else %}
              lock.lock
            {% endif %}  
          target:
            entity_id: lock.your_lock_here

Even if it is a template card?

type: custom:mushroom-template-card
primary: Front Door
secondary: >-
  {% if is_state('lock.front_door_lock', 'locked') and
  is_state('binary_sensor.front_door_contact_contact','off')%}
    Locked
  {% elif is_state('lock.front_door_lock','locked') and
  is_state('binary_sensor.front_door_contact_contact','on')%}
    UnLocked-Open
  {% elif is_state('lock.front_door_lock','unlocked') %}
    Unlocked
  {% endif %}
icon: |-
  {% if is_state('lock.front_door_lock', "locked") %}
    mdi:lock
  {% else %}
    mdi:lock-open-alert
  {% endif %}
layout: vertical
fill_container: true
icon_color: |-
  {% if is_state('binary_sensor.front_door_contact_contact', "off") %}
    green
  {% else %}
    red
  {% endif %}
tap_action:
  action: more-info
hold_action:
  action: none
entity: camera.front_door_medium
double_tap_action:
  action: call-service
  service: |-
    {% if is_state('lock.front_door_lock','locked') %}
      lock.unlock
    {% else %}
      lock.lock
    {% endif %}  
  target:
    device_id: 192b5263584bbe96bb3a26246f796922
  data: {}
card_mod:
  style: |
    ha-card {
      {% if is_state('lock.front_door_lock', 'locked') and is_state('binary_sensor.front_door_contact_contact','off') %}
        background-color: #023702
      {% else %}
        background-color: #370202
      {% endif %}
    }

According to the documentation it does not list templates as supported in the actions. lovelace-mushroom/docs/cards/template.md at 34fd3c90cb649c3f3beda297ce52860388e05f52 · piitaya/lovelace-mushroom · GitHub