Custom button card change bg color

Hi there!
I’trying to change bgcolor of some custom button card based on changed value of attribute current_position (0-100) of the entity cover.tenda_balcone

can anybody help me?

type: vertical-stack
cards:
  - type: custom:button-card
    color_type: card
    color: rgb(,,)
    name: Tenda balcone
    aspect_ratio: 12/1
    entity: cover.tenda_balcone
    state:
      - value: open
        color: rgb(255, 0, 0)
      - value: closed
        color: rgb(0, 181, 157
    show_icon: false
    styles:
      card:
        - color: rgb(3,169,244)
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        name: Chiusa
        entity: script.tenda_balcone_0
        icon: mdi:numeric-0-box
        color_type: card
        tap_action:
          action: toggle
      - type: custom:button-card
        name: 33%
        entity: script.tenda_balcone_33
        icon: mdi:numeric-1-box
        color_type: card
        tap_action:
          action: toggle
      - type: custom:button-card
        name: 66%
        entity: script.tenda_balcone_66
        icon: mdi:numeric-2-box
        color_type: card
        tap_action:
          action: toggle
      - type: custom:button-card
        name: 100%
        entity: script.tenda_balcone_100
        icon: mdi:numeric-3-box
        color_type: card
        tap_action:
          action: toggle

See if using “background-color” works:

        styles:
          card:
            - background-color: '[[[ return variables.background_color_on ]]]'

(This one assumes using a varable called “background_color_on”, which some of the templates included in the custom:button-card documentation use, but you could use something else in its place.)