Need a little assistance in template conditions

Hi all,

I am not the best at coding logic (even go so far as to say I might be the worst). I’d like to ask for some help with a condition template for a door icon (multiple state).

I have a door with a lock (locked/unlocked, lets call this lock.lock) and a state sensor (open/closed, lets call this binary_sensor.door), and i’d like to add a card to my dashboard which will indicate the state of the door through 3 different states:

  1. Door closed and locked - binary_sensor.door=closed and lock.lock=locked
  2. Door closed and unlocked - binary_sensor.door=closed and lock.lock=unlocked
  3. Door open - binary_sensor.door=open and lock.lock=unlocked or locked

I have the card working with the two conditions lock.lock=locked (and by the use of default) lock.lock=unlocked, but cannot for the life of me work out how to do three. Any help would be greatly appreciated.

type: custom:button-card
entity: lock.lock
show_name: false
tap_action:
  action: toggle
color: rgb(255, 0, 0)
state:
  - operator: template
    value: |
      [[[ return states['lock.lock'].state === 'locked' ]]]
    icon: mdi:door-closed-lock
    color: rgb(28, 128, 199)
  - operator: default
    icon: mdi:door-open
    color: rgb(255, 0, 0)
size: 100%
styles:
  card:
    - height: 80px

For your (and our) sanity, keep in mind the custom:button-card uses its own javascript templating engine, unrelated to HA templates :wink: