Lovelace: Button card

You were almost there :slight_smile:
This:
if (states[group] && states[group].state === 'on') count += 1;

Needs to be modified into:
if (states[entity] && states[entity].state === 'on') count += 1;

Edit: typo

1 Like

thanks!
what I feared using ā€˜entityā€™ was whether that references the entity in the main config of the button? It shouldnā€™t.
This template should be an unrelated template completely (in this case the main entity is an automation ā€¦)

Right, itā€™s not the best variable name that I used, but that shouldnā€™t be a problem. The entity in the forEach relates to each element of the array, you can rename it to something else.

my_array.forEach(this_is_one_element => {
  do_something_with(this_is_one_element);
})

Iā€™ll use my brain more next time before typing :blush:

1 Like

no worries :wink:
hoped this to be the case , but with these reserved terms, one never knows :wink:

what if the main button entity would have been the group, and I would have explicitly wanted to reference that here for its group members, how would that have changed the template? In that case we would have referenced ā€˜entityā€™ , but how?

Same but itā€™s :exploding_head:

// this one is the one from the button
entity.attributes.entity_id.forEach(entity => {
                             //        ^^ this is now an element of the array
  thing_with_(entity);
});

thanks! noted in my cookbook.
nothing wrong with your brainā€¦
:pray:

ended up making my own variation with a separate template for fan

image

image

4 Likes

Nice. Is it just an indicator or does it increase the speed?

Itā€™s 3 dashes for high, 2 for medium, and 1 for low.

Yeah I meant if you tap the speed Indicator does it increase?

no, everything is hold actions + a separate UI like @RomRider . I rarely change speed so itā€™s buried in the hold action.

got a new error (I thinkā€¦)

this must be some internal variable, I didnā€™t set it anywhere :wink:

Having the same issue with a timer in a button card which is in a horizontal stack.

Thanks for adding a fix! Iā€™ll be watching for the next release :slightly_smiling_face:

Many thanks for this great and oh-so-useful card - your hard work is much appreciated!

Anyone know if it is possible to set the state-badge of an entity as the icon in a button-card?

The state-badge for a roku media player entity is a graphic of the active roku input. Looking to have the icon of a button card for a roku media player set as the state-badge.

thanks in advance

Awesome cards!

Can you share the template for the light wheel and slider popup?

With show_entity_picture: true?

If you try the beta, it is already fixed

1 Like

Yes please. Can it also be placed vertically?

Something with this GitHub - thomasloven/lovelace-more-info-card: šŸ”¹ Display the more-info dialog of any entity as a lovelace card ?
But how integrate this GitHub - DBuit/light-popup-card: Lovelace card to use as custom pop-up for light in homekit style ?

how can i ā€œtemplateā€ a template? want to make a custom:button-card that shows a label from an other entity. since i use a template iĀ“d like to add the label: into the template.

iĀ“m talking about something like this:

template:

door:
  label: >
    [[[
      return states['{{ ["battery"] }}'].state + "%";
    ]]]

custom:button-card

- type: custom:button-card
  template: door
  entity: binary_sensor.gang
  name: TEST
  battery: sensor.openclose_11_battery_level

so in battery: in the custom:button-card i just put the entity in to show the state of it on label of the button-card.
is this even possible?

door:
  label: >
    [[[
      return states['sensor.openclose_11_battery_level'].state + "%";
    ]]]
- type: custom:button-card
  template: door
  entity: binary_sensor.gang
  name: TEST

if you want to update it for different sensorsā€¦ use the variables

door:
  label: >
    [[[
      return states[variables.battery].state + "%";
    ]]]
- type: custom:button-card
  template: door
  entity: binary_sensor.gang
  name: TEST
  variables:
    battery: sensor.openclose_11_battery_level
3 Likes

works, thanks!