Animation button-card

type: custom:button-card
tap_action:
  action: toggle
entity: switch.portail
show_icon: true
icon: |
  [[[
    if (states['binary_sensor.capteur_portail_contact'].state == 'on')
      return 'mdi:gate-open';
    else
      return 'mdi:gate';
  ]]]
name: Portail
styles:
  card:
    - border: none
    - background: |
        [[[
          if (states['binary_sensor.capteur_portail_contact'].state == 'on')
            return 'red';
          else
            return 'gray';
        ]]]
    - animation: |
        [[[
          if (states['binary_sensor.capteur_portail_contact'].state == 'on')
            return 'bgcolorswap 2s linear infinite';
          else
            return 'none';
        ]]]
extra_styles: |
  @keyframes bgcolorswap {
    0% {
      background-color: red;
    }
    50% {
      background-color: gray;
    }
    100% {
      background-color: red;
    }
  }

Ce coup-ci c’est bon :grin: Je dois être un peu fatigué

2 « J'aime »