Custom:Button-card icon color change

I created a binary sensor (Aqara T1 Door Sensor) button card which calls a script to turn on my A/C on tap action. This function works fine, and I’m also able to change the state name to On/Off instead of the default Open/Closed.

However, I have difficulty changing the icon color based on the state. Below is my code, is there anything I’m doing wrong?

type: custom:button-card
entity: binary_sensor.living_room_air_con_sensor_contact
name: Air Con
show_name: false
show_state: true
size: 30%
tap_action:
  action: call-service
  service: script.living_room_air_con_toggle
color_type: icon
color: |
  [[[
    if (entity.state === 'off')
      return 'Green'
    else
      return 'Grey'
  ]]]
state_display: |
  [[[
    if (entity.state === 'off')
      return 'Off'
    else
      return 'On'
  ]]]

I’ve also tried using;

  state:
    - value: 'On'
      color: Green
    - value: 'Off'
      color: Grey

The icon color changes to yellow despite the above coding, which seems to be the default color for this senor/entity.

Bumping if anyone has any idea on my issue. Thanks.

Suggest you to never create separate threads for this card and ask similar questions in the already present dedicated huge button-card thread. You will help keeping solutions in one place and probably get your answer much faster.

Noted. Thanks.