Skip to content

Commit

Permalink
Add last updated property to tile card state content (#21191)
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya authored Jun 27, 2024
1 parent 49c42fc commit 5273293
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/panels/lovelace/cards/hui-tile-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down
3 changes: 2 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 5273293

Please sign in to comment.