Problem with custom button card value

Hi,

I’ve a problem on a custom button card configuration, i want to change icon color with value, every day the value incremented by +1 and when the value is over 6 the icon have to change from green to red, everything work fine except when the value is 10 or more, the icon return to green, i realy don’t understand what is going on, from 1 to 6 the icon is green, from 7 to 9 the icon turn red, and what i dont understand from 10 the icon return to green …

There is the configuration :

type: custom:button-card
entity: counter.jour_depuis_dernier_rangement_bureau
icon: mdi:desktop-tower-monitor
name: Rangement Bureau
color: green
styles:
  card:
    - height: 200px
    - font-size: 18px
    - font-weight: normal
state:
  - value: "6"
    operator: ">"
    color: red

i also try with this :

type: custom:button-card
entity: counter.jour_depuis_dernier_rangement_bureau
icon: mdi:desktop-tower-monitor
name: Rangement Bureau
color: green
styles:
  card:
    - height: 200px
    - font-size: 18px
    - font-weight: normal
state:
  - value: "6"
    operator: ">"
    color: red
  - value "9"
    operator : ">"
    color : red

Same problem, when it go 10 or over the icon return to green.

Sorry for my bad english.

Thank You

The use of " indicate it is a strong and not a number.

Perhaps this could be more intuitive?

  - type: custom:button-card
    entity: ...
    icon: ...
    name: xxxx
    styles:
      card:
        ...
      icon:
        - color: >-
            [[[
              let STATE = entity.state;
              if (STATE > 66)
                return 'red';
              else
              if (STATE > 33)
                return 'yellow';
              else
                return 'green';
            ]]]

That

state:
  - value: ...
    operator: ...
    ...
  - value ...
    operator : ...
    ...

imho is mainly for people who do not want to deal with JS templates.

Thank you i try with ’ instead of " it doesn’t work but without anything just the value it work pretty fine !!!
Thank you really appreciate

i try it but my entity doesn’t have xxxxx.state and when i paste my entity (counter) it doesn’t want to work, but thank you for the code i’m a newbie on home assistant and you learn me something interresting

Both are indicators for strings here.
They interpret escaped characters differently, AFAIK, but they are both strings.
Not using anything makes it a number.

Thanks for the explaination, now i’m ready for my others automation with numeric value state !