How do I print attribute information in a if elif statement

Good morning,
I’m running into a formatting problem a a mushroom template card. I’m using the template card for my iBlinds motors, as the data I need to put on the card is more complex than the standard mushroom cover card will permit. I’m trying to replicate the look of the card in some aspects, which is becoming a challenge.

For the secondary information on the card, I want it like the mushroom cover card. If the blind is closed, it should state of course “Closed”. If it’s open, it should state “Open”, with the open percentage. That open percentage is an attribute of the state of the cover entity.

Here is what I’m attempting:

        secondary:  |-
          {% if is_state('switch.office_blind_left', 'off') %}
            Closed
          {% elif is_state('switch.office_blind_left', 'on') %}
            'Open - {{ state_attr(''cover.office_blind_left'', ''current_position'') }}%'
          {% endif %}

And this is what I end up with.

The Closed part of the if statement works just fine.

If I were to just put the code (without ‘Open -’ preceding) for Open as the secondary value, it would also work just fine.

What do I need to do to fix this?

Try this:

            Open - {{ state_attr('cover.office_blind_left','current_position') }}%

That did it. I swore I tried it, and every iteration. Must be gremlins.

1 Like

Glad I could help. Sometimes a 2nd pair of eyes is all that’s needed :slight_smile: