Lovelace: Button card

It’s a main option at the root level. It’s in the doc’s in the main options table.

1 Like

Can’t believe I missed that, thanks!

1 Like

It’s a big table, super easy to miss stuff.

@brucehvn, I’ve published a beta release that should fix your issue with nested cards. Would you mind testing? (If you’re using HACS, display the beta releases to be able to install it)

@AhmadK, I’ve also added a better way of handling updates in this release: It only updates when needed and there is some auto-discovery of entities used in templates (I said I wouldn’t do it but in the end I did it :smiley:). However, it’s still possible to add manually entities that would trigger an update or keep the old behaviour and update every time anything is updated in HA.

@all, if you want to test and report back, that would be great. Please read the release notes of the beta there are important information! I plan to release it in some days after people had some time to test (@petro, @Mariusthvdb, @jimz011, … thinking about you here :stuck_out_tongue: ).

It should improve a lot the reactivity of the frontend on low-end devices :slight_smile: (and consume less on high end mobile devices)

1 Like

On it :grinning:

Hi @RomRider,
Great! hope this will ease up my main issue in the config… Lovelace taking a lot of resources for HA, which has its consequences down the system (mainly Hue entities going unavailable all the time). Since the button-card is on each and every page, this has its consequences so I learn now. Had suspicion of that before, but since you are so abundantly clear about it now, I will put all effort on this now.

So, eager to test!

before I do, please let me know how to have the new card update with ‘entity’ in templates/decluttering cards.
If I understand the notes on the new functionality correctly, it only works with hard-coded entities? that would really be un-useful, because most buttons in my setup use templates, not only in the JS department, but fir the main entity of the button itself.

please let me know?
thanks

thanks for the beta!
I can see some broken behaviour when using it, will investigate and report back.
actually, it’s not that bad - apparently it now requires explicit mention of my entity in triggers_update

UPDATE: from my end it looks good, tried it with no triggers_update and noticed some cards not updating because they had templates that use other entities (fixed it by adding their names to triggers_update).
So it seems to work, well done!!
2 polite requests here if I may:

  1. It would be fantastic if triggers_update could accept a list or a string, just one name:
triggers_update: sensor.test

instead of

triggers_update:
  - sensor.test

or

triggers_update: [sensor.test]
  1. Please pay attention to this note - I haven’t hit by it so far as my config is tiny, but I have a feeling that for some it might be a show stopper (with the only option of lovelace_gen maybe?). Maybe you can support templates here? (I know it sounds crazy but…)

but it’s beta, hey!

Seems like triggers_update are combined when using template: so it’s jolly good!

LL is frontend it doesn’t put load on where HA is running! Nothing has changed @Mariusthvdb from what I said before in this thread.

Just to be clear, this will not change anything on the backend (= where HA is installed, a raspberry pi for example), it will only make the frontend a bit snappier (= device where you display the interface, your phone for example) if you have a lot of of button-cards :wink:

1 Like

I think you would need to make a sensor that counts the amount of lights in a given room and then use that on the card.

Thanks, I have the sensor. I just cant figure out how to get it to show that sensor in the corner like that.

Is it possible or maybe a feature request to allow a tap action on a label that is different to the main card?

I have a temperature of the room listed in a label which I would want to show something else if you tap the label.

Maybe it’s better to use a custom entity instead and put that on the card with the grid system?

You need to use the custom bit of the card to create a new section. Add your sensor state to that and it will appear. However you need to adjust the grid layout for it to appear properly.

Yes, this is the way! :smile:

The main entity of the button doesn’t support [[[ ]]] templates :slight_smile:
It only works with hard-coded entities, yes, but you can add entities to the list of monitored entities. There is no way to do differently and it is the same in HA’s backend for template entities for example

1 Like

Could you please show me the config in this case?

tiggers_update: [ "sensor.test" ] #note the quotes
# is the same as:
triggers_update:
  - sensor.test

But yes, I’ll add the support for triggers_update: sensor.test directly

you know that’s not what I meant ;-)… I hope.

let me ask it then:

button_light:
  label: >
    [[[
    var bri = Math.round(entity.attributes.brightness / 2.55);
    return (bri ? bri : '0') + '%';
    ]]]
  color: auto-no-temperature
  size: 30%
  aspect_ratio: 1/1
  tap_action:
    action: toggle
    haptic: light
  hold_action:
    action: more-info
    haptic: success

is a template used by a button:

      - type: custom:button-card
        template: button_light
        entity: light.drawer

do I, and if yes, where, need to add a triggers_update anywhere in this setup?

You don’t need to do anything in this case. button-card template or not there is no difference.

that is what is being said, I know.
Still, how then can only hitting the refresh option in Lovelace cause Hue to become unavailable. (this is a very long story, search ‘hue unavailable’, and still is not resolved) There must be some interaction between the Lovelace frontend, and the HA backend to cause that.

I was merely hoping that your Lovelace frontend improvement with the new Button card would at least ease up on that. Not saying that it does cause issues now, but still hope it would be an improvement.

ok cool. that is a relieve… :wink:
otoh, it won’t improve either then? Or do the changes you made in the background still improve updating per entity/button

If the place where HA is running is low-end (a raspberry pi for example) and knowing that you have a lot of things in place inside HA (atuomation and a lot of entities) and a huge LL config, while refreshing the page, I/O might be too high to handle for your low-end device and this might be the reason why some entities do not have proper behavior (in the backend).
Regarding specifically hue lights, they also from time to time become unavailable for me, even without refreshing the page and I have a high end server to run my Home-Assistant instance :slight_smile:

In this case, there will be improvements: It will only update when the entity is updated, not every time any entity is updated as before.
I will update the release notes to say that it will automatically update for the entity in the entity + all the auto-discovered entities in the js [[[ ]]] templates (inside template or not doesn’t change anything) + all the entities of triggers_update if defined.

1 Like