Lovelace: Button card

@kuuji would it be possible to use label templates in a future update by any chance please?

For example, I have the following buttons where the number of open windows/doors shows within the text:
image

I call this using:

label_template: "return 'All Lights: ' + entities['sensor.lights_on'].state;"

which was possible using Custom UI Tiles (no longer developed which is a shame).

Given that the code was removed from GitHub by the dev (grr), I’ve searched for “label_template” within the code to give the following extract just in case it helps.

   computeLabel(hass, entity) {
      if (entity.label) {
        return entity.label;
      } else if (entity.label_template) {
        return this.computeFromTemplate(hass, entity, 'label_template');
      } else if (entity.label_state || DOMAIN_SENSOR.includes(entity.entity.split('.')[0])) {
        const stateObj = hass.states[entity.label_state];
        if (stateObj) {
          return stateObj.attributes && stateObj.attributes.unit_of_measurement ? `${stateObj.state} ${stateObj.attributes.unit_of_measurement}` : stateObj.state;
        }
      }
      return '';
    }

    hasLabelSec(entity) {
      return entity.label_sec || entity.label_sec_state || entity.label_sec_template;
    }

    computeLabelSec(hass, entity) {
      return this.computeLabel(hass, {
        label_template: entity.label_sec_template,
        label_state: entity.label_sec_state,
        label: entity.label_sec,
        entity: entity.entity });
    }

The original code can be found via a link here: Custom UI: Tiles

On another note, can we span buttons like the above screenshot example?

1 Like