Custom Button color based on sensor state

Hello, I want to set the color button with a created sensor to get and format to a string the last RGB value sent by a light.
Button card :

type: custom:button-card
entity: switch.table_pixel_1
icon: none
show_name: false
styles:
  card:
    - color: white
state:
  - value: 'on'
    styles:
      card:
        color: >
          [[[
            return 'states['sensor.table_color_rgb'].state';
          ]]]

Sensor Created :


image

Thanks for your help

Try


color: >
  [[[
    return states['sensor.table_color_rgb'].state;
  ]]]

I got this error :
image

Any idea ?

Post your card code.

type: custom:button-card
entity: switch.table_pixel_1
icon: none
show_name: false
styles:
  card:
    - color: white
state:
  - value: 'on'
    styles:
      card:
        color: >
          [[[
            return states['sensor.table_color_rgb'].state;
          ]]]

The hyphen is missing:

card:
  - color: