Add last updated property to tile card state content (#21191)

This commit is contained in:
Paul Bottein 2024-06-27 18:46:39 +02:00 committed by GitHub
parent 49c42fc757
commit 5273293cd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View File

@ -238,6 +238,14 @@ export class HuiTileCard extends LitElement implements LovelaceCard {
></ha-relative-time>
`;
}
if (content === "last-updated") {
return html`
<ha-relative-time
.hass=${this.hass}
.datetime=${stateObj.last_updated}
></ha-relative-time>
`;
}
if (content === "last_triggered") {
return html`
<ha-relative-time

View File

@ -201,6 +201,12 @@ export class HuiTileCardEditor
),
value: "last-changed",
},
{
label: localize(
`ui.panel.lovelace.editor.card.tile.state_content_options.last-updated`
),
value: "last-updated",
},
...Object.keys(stateObj?.attributes ?? {})
.filter((a) => !HIDDEN_ATTRIBUTES.includes(a))
.map((attribute) => ({

View File

@ -5987,7 +5987,8 @@
"state_content": "State content",
"state_content_options": {
"state": "State",
"last-changed": "Last changed"
"last-changed": "Last changed",
"last-updated": "Last updated"
}
},
"vertical-stack": {