Home Assistant Community

Lovelace: Button card


Hi all

Is it possible to evaluate an attribute of an entity instead of the state, like this

          - position: 40
            color: rgb(255, 0, 0)



I wish this button had a hold action still kinda surprised almost no one asks for this feature :stuck_out_tongue:

The core button works fine though, though I can’t color the buttons.


Also interested in seeing how @gurukid did that !



  • color: ‘#f8f8f8
    color_type: labelcard
    name: Office Lamp
    • border: ‘1px solid #ccc
    • box-shadow: 0px
      type: ‘custom:button-card’
  • cards:
    • color: ‘rgb(66, 134, 244)’
      color_type: icon
      entity: light.office_lamp
      icon: ‘mdi:lamp’
      show_state: true
      • color: ‘#fdbc22
        value: ‘on’
        type: ‘custom:button-card’
    • color: ‘#fff
      color_type: card
      entity: script.dimoffice10
      icon: ‘mdi:signal-cellular-1’
      name: dim 10%
      • color: ‘#f5f5f5
        value: ‘off’
        type: ‘custom:button-card’
    • color: ‘rgb(213, 0, 96)’
      color_type: card
      entity: script.dimoffice50
      icon: ‘mdi:signal-cellular-2’
      name: dim 50%
      • color: ‘#f5f5f5
        value: ‘off’
        type: ‘custom:button-card’
    • color: ‘rgb(66, 134, 244)’
      color_type: card
      entity: script.dimoffice100
      icon: ‘mdi:signal-cellular-3’
      name: dim 100%
      • color: ‘#f5f5f5
        value: ‘off’
        type: ‘custom:button-card’
    • action: more_info
      color: ‘#fdbc22
      color_type: icon
      entity: light.office_lamp
      icon: ‘mdi:selection-ellipse’
      name: Custom %
      type: ‘custom:button-card’
      type: horizontal-stack
      type: vertical-stack

can you share the config for the link button, that would be awesome… :slight_smile:


Can I have a custom background colour for the card dependent on state and a custom icon at the same time?

So white background and icon A for off, then blue background and icon B for on. From my experimentation it seems you can only do one or the other, is this correct?


I’ve been wanting this for a while as well. I have looked through the code to try and add on hold, but since it’s not using HTML elements I can’t figure out how to add it to the current set up. I’ll mess around with it a bit more this weekend.


I think our time is better spent trying to improve entity-button. Feel free to contribute to core. Should get show/hide icon/name soon


Indeed I think this is better as well, for that reason I have reverted back to the core button as I need the hold action. It would be better if some of this cards features come to core like button color for example.

Pretty happy with the core button now, as the hold action finally works as it should on my iphone whereas it wouldn’t before (and thus the reason why I started using this custom card). Still some features would be nice like the empty button for example.


Sounds like a better idea indeed. For some reason the show/hide options are on the docs, but don’t seem to be working yet :frowning:

Also I managed to get pretty similar results using entity-button, the one thing I’m mainly missing is the card background coloring instead of just the icon coloring.


Those shouldn’t have been merged, I put them against next with a linked PR, but the frontend PR has not been merged

Will be in 0.91


Is that going to include changing the icon colour according to the state (like currently for switches & lights)?


My PR? No. It’s for show/hide of name/icon


Are you still planning on moving those other features over to core entity-button?

1 Like

My point was that people not be trying to hack this card to work for them, they are better off contributing to core. I do have any concrete plans on what features will be brought over.


Doc’s got updated a little too soon. Was wondering why that didn’t work when I tried it Wednesday. EDIT: Referring to show/hide icon/text.


I would also look forward to having some of the options with this card be brought to the Lovelace default one. Unfortunately, the default one lacks any real uses for me if it doesn’t include features such as icon/background changing on state, sizing etc. It would be also nice to have more advance features such as an entity to toggle and another to display the text. I get the feeling that for simplicity this will never make it into the core so I think there will always be a need for custom Lovelace components as I’m sure quite a few on this thread agree.

1 Like

The only reason I ever used this custom card was so I could change the icon colour when the state changes. The core card does this for lights and switches but nothing else… if the core card had that then I’d use it.


I never said custom cards as a whole. I make custom cards all the time. But splitting the effort on a button doesn’t make sense anymore.


I was also just referring to button-card. I think there is a place for having both. There are lots of uses for advanced features of a button card that doesn’t seem to jive with the direction of the default cards in Lovelace. But if somehow these features could make it into the default card that would be ideal.