Lovelace animation

Hi All, I am trying to have a rotating fan icon when the A/C is on. I created and extra button card with the climate entity, the fan mode is an attribute for this entity. how can I make a conditional logic to be rotating only when the A/C is running.

I tried the following code but it didn’t work.

type: custom:button-card
entity: climate.basement
show_state: true
state_display: |
[[[ return (entity.attributes.hvac_action)
]]]
state:
- value: cool
styles:
icon:
- animation: |
[[[ if ``(states['entity.attributes.hvac_action'].state == idle)
return 'rotating 2s linear infinite'
]]]

At least you got a wrong indentation.
Goto button-card thread for details.

P.S. Similar questions should be asked in a dedicated button-card thread.