Button color and icon based on binary_sensor state

Hi there! I am trying to get a button working that shows the state of my ikea door sensor. I have managed to do the following:

type: custom:button-card
entity: binary_sensor.ikea_window_sensor_1_offnung
icon: none
show_name: false
styles:
  card:
    - color: white
state:
  - styles:
    card:
    - color: >
          [[[
            return states['binary_sensor.ikea_window_sensor_1_offnung'].state === 'open' ? 'red' : 'green';
          ]]]

This does not seem to work though, the button is just grey.
Thanks for help!

i use this

type: custom:button-card
color_type: icon
entity: binary_sensor.hoveddoren
layout: icon_label
label: Hoveddør
show_label: true
show_name: false
size: 30%
color: green
state:
  - value: "off"
    color: rgb(255, 0, 0)
styles:
  card:
    - font-size: 12px

Wrong, binary sensor can be “on/off”.