Trying to create a simple tap button to lock and unlock my door

Hi guys,

I’m pretty much frustrated by a simple tasks that I just can’t solve.
all I want is a button that will lock if door lock is open and unlock when it’s closed.
I’ve tried the following syntax but no success:

card:
          type: button
          name: Door Lock
          entity: lock.schlage_touchscreen_deadbolt_door_lock
          show_state: true
          state:
            - value: "locked"
              color: green
              icon: mdi:lock
            - value: "unlocked"
              color: red
              icon: mdi:lock-open-variant
          tap_action:
            action: >
               {% if is_state('lock.schlage_touchscreen_deadbolt_door_lock', 'locked') %}
                 lock.unlock
               {% else %}
                 lock.lock
               {% endif %}
            data:
              entity_id: lock.schlage_touchscreen_deadbolt_door_lock

what am I missing here?

Thanks!

Please start by editing your post to use code blocks around YAML.

You should know that a single white-space character can prevent a configuration from working at all; let alone making it more readable to those trying to help.

Sorry about that, this is basically my first post.

What does it do and not do when you press the button? Does any part of it work?

unfortunately, it doesn’t do anything…

Are you sure the states are locked and unlocked? Not true and false or 0 and 1 or a million other things that a binary s=device can be?

I ended up using a picture elements card. I had to combine some more info so that was the only option I had.