Buttons change color and icon depending on the thermostat status

hi,
I created three buttons that turn thermostatic valves on and off, changing color depending on which one is activated.
When I turn it off, all three change color.
The problem is that the auto or quick function is active, only off status chenge color, auto and quick work together.
I’d like the thermostat to be off with the blue button, auto and rapid gray.
Thermostat to be on auto yellow, off and rapid gray.
Thermostat to be on rapid red, off and auto gray.

doesn’t work correctly


type: horizontal-stack
cards:
  - type: custom:button-card
    entity: group.valvole_termostatiche
    state:
      - value: "off"
        icon: mdi:home-thermometer-outline
        color: cyan
      - value: "on"
        icon: mdi:home-thermometer-outline
        color: grey
    show_entity_picture: true
    show_state: true
    tap_action:
      action: toggle
    hold_action:
      action: none
    name: Spento
  - type: custom:button-card
    entity: group.valvole_termostatiche
    state:
      - value: "off"
        icon: mdi:home-thermometer
        color: grey
      - value: "on"
        icon: mdi:home-thermometer
        color: orange
    show_entity_picture: true
    show_state: true
    tap_action:
      action: call-service
      service: climate.set_hvac_mode
      target:
        device_id:
          - 4cef777a13f5926da8ab6f5f2a5b47dc
          - 3b29c1c82018d44715b3aca2138a287d
          - b4724d440819d1133fd7b74080224bef
          - 4dc68d7f24e8be2e8dc5c565c6fa0ebd
          - fbdf8a64551c3caa78039d3708c4a949
          - e2dba89e790f266a8423f9cd5b34111d
          - ed10ac03c49cf48aa1997e7d547fee82
      data:
        hvac_mode: auto
    hold_action:
      action: none
    name: Programmato
  - type: custom:button-card
    entity: group.valvole_termostatiche
    state:
      - value: "off"
        icon: mdi:fire
        color: grey
      - value: "on"
        icon: mdi:fire
        color: red
    show_entity_picture: true
    show_state: true
    tap_action:
      action: toggle
    hold_action:
      action: none
    name: Rapido

Please format your code as explained here: