Assistance with custom button card

I’ve replicated an existing Garage door button card to apply to a different entity.so I’ve changed the referenced entity as well as icons and for some reason the colours are incorrect and the icon is not changing as the state changes either. YAML is below. Any suggestions would be greatly appreciated.

type: custom:button-card
entity: binary_sensor.front_gate_sensor_contact
show_name: false
state:
  - value: Closed
    color: rgb(92,184,92)
    icon: mdi:gate
  - value: Open
    color: rgb(255,193,7)
    icon: mdi:gate-open
  - value: unknown
    color: rgb(217,83,79)
    icon: mdi:gate-alert
    styles: null
    card:
      animation: blink 2s ease infinite
  - value: unavailable
    color: rgb(217,83,79)
    icon: mdi:gate-alert
    styles: null
    card:
      animation: blink 2s ease infinite
tap_action:
  action: call-service
  service: switch.turn_on
  target:
    entity_id: switch.front_gate_switch_0
  confirmation:
    text: Do you want to open the front gate?
hold_action:
  action: more-info

Hi, are the states values correct/corresponding to the sensor?
Try with the states values between double quotes.

I’ve confirmed the values are correct. Funny thing is when I enclose them and then and reopen the card to edit the quotes are no longer present.

States are on/off, lowercase.
Also, check “styles” option, it has unindentent content.
Quotes are not needed for strings (if the do not contain colons), that is why they are auto-deleted.

1 Like

Missed that one!
:bowing_man:

Ok thanks. How does the on/off map to the sensor’s values of Open or Closed?

You may find out this yourself: close the physical door , check if the sensor is “Closed”, find a real state in “Dev tools → State”

1 Like