Icon change within custom button card

Welcome huascar,

you are trying to use Jinja in custom:button card. Use the following instead:


icon: >
  [[[
    if (states['sensor.front_door_power'].state < 50) return 'mdi:alert-decagram';
    return 'mdi:battery';
  ]]]

Or shorter, because you have a „main“ entity (= sensor.front_door_power):


icon: >
  [[[
    if (entity.state < 50) return 'mdi:alert-decagram';
    return 'mdi:battery';
  ]]]

I can highly recommend the main discussion https://community.home-assistant.io/t/lovelace-button-card/65981