Where to find the source for Lovelace cards?

HI,

on all Home-assistant components, we can find the source in the right hand side of the component documentation:

20

trying to find/read/understand the source for the native HA Lovelace cards, no such source link is provided afaics.

Where can we find the source for the Lovelace cards?

rows for entity_card

cards

a yes, thanks.
trying to find where the secondary_info options are configured (would love to have the extra possibility for last-triggered…) but it isn’t in this source I am afraid
or would that be set in a helper card of sorts?

Are you referring to these?

no, I dont think so.
I’m looking for the place/file/source where the secondary_info is configured.
Just so I could see if my FR to add last-triggered would be feasible.

Please @iantrich could you point me to the source for that? (sorry for the tag, wouldn’t know how else to ask you tbh…)

thanks, but…where exactly? I mean to find where this defined in the source files of the entities card:

03

Didn’t read the full thread previously; that’s here https://github.com/home-assistant/home-assistant-polymer/blob/1c614c855f473784e0dd361029ad4f26e2f6a05f/src/panels/lovelace/components/hui-generic-entity-row.ts. Line 101

yes! that’s it, thank you!

would it be an enormous undertaking to add last_triggered as available value? Looking at that code, it seems feasible… #fingerscrossed

: this.config.secondary_info === "last-triggered"
              ? html`
                  <ha-relative-time
                    .hass=${this.hass}
                    .datetime=${stateObj.last_triggered}
                  ></ha-relative-time>
                `
              : ""

would be really very useful…
created a PR https://github.com/home-assistant/home-assistant-polymer/pull/4222 hoping this will be acceptable

Yeah… that’s not where last_triggered is located. Also, it’s not on all state objects, only automations. That PR probably won’t make it.

EDIT: Just to clarify, last_triggered is inside attributes. Some major changes would be required to display attributes in the secondary info location. It’s not a bad idea, but it should be implemented to accept any generic attribute. Not just a hardcoded single attribute. Even then, with the generic attribute a new field would probably be needed to identify the type of attribute so that the UI formats it properly. Your best option is to make a sensor template with the device_class: timestamp. Then use a custom card to display that attribute as a secondary-info.

o yes, you’re right, should correct it to:

: this.config.secondary_info === "last-triggered"
              ? html`
                  <ha-relative-time
                    .hass=${this.hass}
                    .datetime=${stateObj.attributes.last_triggered}
                  ></ha-relative-time>
                `

passed!


and, just so you feel the need a bit more, I use this attribute last_triggered on for scripts also, triggering automations

trigger:
  platform: state
  entity_id: script.triggering_script

having an entities card with these scripts, showing their last_triggered attribute would be an anticipated addition to the dashboard.

So, automations and scripts are a maybe small, but important reason enough to validate the addition to the secondary-info line. I hope…

yes, thanks, useful suggestion, and I use several of these kinds. My hope though is to ‘improve’ native Ha cards in such a way, we dont need template sensors for everything out of the ordinary.

My point is that it won’t make it because it’s not generic. If you put a light entity in that field with last-triggered, it will error because the attribute doesn’t exist. I understand you want this, but you gotta make it work for ALL entities.

understand. well, there is the ‘else’ in the template :"" which would safeguard a case like that?

if not, if must be, I guess in stead of using:

  - type: entities
    entities:
      - entity: script.triggering_script
        secondary_info: last-triggered

we will be forced to keep using:

  - type: entities
    entities:
      - type: 'custom:secondaryinfo-entity-row'
        entity: script.triggering_script
        secondary_info: '[[ {entity}.attributes.last_triggered ]]'

or your template sensor suggestion

That safeguards against the input in your configuration, not weather or not the attribute exists in the state object.

yes, Ive learned that now…
Bram suggested this test, which I have added of course:

: this.config.secondary_info === "last-triggered" && stateObj.attributes.last_triggered

Yah, that would work. Bram is willing to approve a change like that? If so, I might add some things i’ve wanted.

it’s here: Add secondary_info: last-triggered for entities-card

cool.

can even use in the auto-entities card by @thomasloven

  - type: custom:auto-entities
    card:
      type: entities
      title: All Automations auto
      show_header_toggle: false
      type: entities
    filter:
      include:
        - domain: automation
          options:
            secondary_info: last-triggered

#  - type: custom:monster-card
#    show_empty: false
#    card:
#      type: entities
#      title: All Scripts
#      show_header_toggle: false
#    filter:
#      include:
#        - domain: script

  - type: custom:auto-entities
    card:
      type: entities
      title: All Scripts auto
      show_header_toggle: false
      type: entities
    filter:
      include:
        - domain: script
          options:
            secondary_info: last-triggered