Changing Name of custom:button-card with Conditional

Hey guys, I know there have been many variations of this posted and I’ve read through loads of them and I can’t figure out what is happening with my ‘if’…

My goal is to change the name of a button based on the value of a input_text.

  - type: custom:button-card
    entity: script.goodnight
    show_name: true
    show_icon: true
    tap_action:
      action: toggle
    name: >
     {% if is_state('input_text.house_phase', 'Sleep') %}
        SLEEP
     {% else %}
        GOODNIGHT
     {% endif %}

(I hope I’ve inserted that correctly… my first time!)

Thoughts?

mr.smith

Custom button-card supports JS templates.
https://custom-cards.github.io/button-card/stable/advanced/js-templates/#how-to-use-a-js-template

Thank you! That is exactly what I needed to know!

1 Like