if-Bedingung für Textanzeige bei einer Bestätigung (confirmation)?

Hallo,

ich habe in einer Karte eine Bestätigung (confirmation) eingebaut, die beim “Verhalten bei Antippen” (tap_action) ausgelöst wird.
https://www.home-assistant.io/dashboards/actions/#options-for-confirmation
Das funktioniert auch soweit.

Um die Karte variabler zu gestalten, wollte ich bei der confirmation eine if-Bedingung für die Textanzeige einbauen.
Das funktioniert aber mit meiner getesteten Syntax nicht.
Frage:
Ist eine if-Bedingung bei der Textanzeige nicht möglich?
Oder ist meine Syntax falsch?

Diese confirmation funktioniert NICHT:

  confirmation:
    text: |
      {% if is_state(entity, 'off') %}
        Öffnen?
      {% else %}
        Schließen?
      {% endif %}
    title: Garage
    confirm_text: Ja
    dismiss_text: Nein

Diese confirmation funktioniert NICHT:

  confirmation: |
    {% if is_state(entity, 'off') %}
      text: Öffnen?
      title: Garage
      confirm_text: Ja
      dismiss_text: Nein
    {% else %}
      text: Schließen?
      title: Garage
      confirm_text: Ja
      dismiss_text: Nein
    {% endif %}

Komplette Karte mit confirmation:
(confirmation funktioniert NICHT)

type: custom:mushroom-template-card
entity: binary_sensor.status_garage_matthias_invertiert
primary: Garage Matthias
secondary: |
  {% if is_state(entity, 'off') %}
    Geschlossen
  {% else %}
    Geöffnet
  {% endif %}
icon: |
  {% if is_state(entity, 'off') %}
    mdi:garage
  {% else %}
    mdi:garage-open
  {% endif %}
color: |
  {% if is_state(entity, 'off') %}
    green
  {% else %}
    red
  {% endif %}
tap_action:
  action: perform-action
  confirmation:
    text: |
      {% if is_state(entity, 'off') %}
        Öffnen?
      {% else %}
        Schließen?
      {% endif %}
    title: Garage
    confirm_text: Ja
    dismiss_text: Nein
  perform_action: switch.turn_on
  target:
    entity_id: switch.garage_matthias_shelly1
features_position: bottom

Komplette Karte ohne confirmation:

type: custom:mushroom-template-card
entity: binary_sensor.status_garage_matthias_invertiert
primary: Garage Matthias
secondary: |
  {% if is_state(entity, 'off') %}
    Geschlossen
  {% else %}
    Geöffnet
  {% endif %}
icon: |
  {% if is_state(entity, 'off') %}
    mdi:garage
  {% else %}
    mdi:garage-open
  {% endif %}
color: |
  {% if is_state(entity, 'off') %}
    green
  {% else %}
    red
  {% endif %}
tap_action:
  action: perform-action
  perform_action: switch.turn_on
  target:
    entity_id: switch.garage_matthias_shelly1
features_position: bottom

Soweit ich weiß ist “templating” in tap_action bei Mushroom nicht möglich. Dafür könnte man die custom-button_card benutzen.

Versuch mal sowas:

type: custom:button-card
entity: binary_sensor.status_garage_matthias_invertiert
name: Garage Matthias
show_icon: true
show_name: true
show_state: true

state_display: |
  [[[
    return entity.state === 'off' ? 'Geschlossen' : 'Geöffnet';
  ]]]

icon: |
  [[[
    return entity.state === 'off' ? 'mdi:garage' : 'mdi:garage-open';
  ]]]

tap_action:
  action: perform-action
  confirmation:
    text: |
      [[[
        return entity.state === 'off'
          ? 'Garage Matthias öffnen?'
          : 'Garage Matthias schließen?';
      ]]]
  perform_action: switch.turn_on
  target:
    entity_id: switch.garage_matthias_shelly1

styles:
  card:
    - padding: 12px
  grid:
    - grid-template-areas: '"i n" "i s"'
    - grid-template-columns: 48px 1fr
    - grid-template-rows: min-content min-content
    - column-gap: 12px
  img_cell:
    - width: 48px
    - height: 48px
  icon:
    - width: 32px
    - color: |
        [[[
          return entity.state === 'off' ? 'green' : 'red';
        ]]]
  name:
    - justify-self: start
    - align-self: end
    - font-size: 14px
    - font-weight: 500
  state:
    - justify-self: start
    - align-self: start
    - font-size: 12px
    - color: var(--secondary-text-color)

Warum hantierst Du überhaupt mit einen Binary Sensor und einem Switch.
Mit diesen Beiden kannst Du Dir doch eine Template Cover erstellen. Dann hast Du auch einen Cover Entität um Dein Garagentor zu steuern.

Gruß Osorkon

Weil ich das mal in einem Video so gesehen habe.

Template Cover? Sag mir (noch) nichts.
Aber ob ich mich da reinfielsen kann…

Ich habe mir die Seite angesehen:
https://www.home-assistant.io/integrations/template/#cover
Komme aber nicht weiter.

Es werden zwar immer schön die Parameter erklärt.
Aber wie soll ich das dann konkret umsetzen ohne Beispiele?

Vermutlich bräuchte ich das hier:
State based cover - Optimistic Garage Door with Momentary Switch

Aber welches Template muss ich dafür überhaupt wählen?
Ich habe mich für “Abdeckung” entschieden.
Aber ich kann das Template ja nicht mal speichern.
Irgendwas will er noch von mir.

Außerdem brauche ich nur einen Button zum steuern und nicht öffnen/stop/schließen.
Ich kann nur einen Knopf rücken und das Tor reagiert entsprechend je nach Position bzw. Laufzustand.

:crayon:by HarryP: Zusammenführung Doppelpost (bei Änderungen oder hinzufügen von Inhalten bitte die „Bearbeitungsfunktion“ anstatt „Antworten“ zu nutzen)

Hier mal ein Bsp.

Gruß Osorkon