lovelace-multiple-entity-row icon indicating copy to clipboard operation
lovelace-multiple-entity-row copied to clipboard

FR: Add new secondary info option - logbook-last-changed

Open danielbrunt57 opened this issue 1 year ago • 5 comments

...or something like that. My idea stems from this custom logbook card which can display an entity's history from the logbook. I am only interested in the most recent logbook entry rather than being stuck with HA's secondary_info: fields last-updated & last-changed which all get reset when HA starts/restarts.

image

My HA was restarted 2 hours ago and so last-updated & last-changed are all now 2 hours ago...

image

danielbrunt57 avatar Jul 24 '22 22:07 danielbrunt57

My HA was restarted 2 hours ago and so last-updated & last-changed are all now 2 hours ago...

Do you want a custom card to keep somewhere an actual last-changed value for ALL entities? A card may only display/process some existing states/attributes. Since an object does not keep these "actual last-changed/updated" - there is nothing to display/process.

I am only interested in the most recent logbook entry

What if an entity is excluded from Recorder?

Finally, I do not see any connection between multiple-entity-row and the Logbook.

ildar170975 avatar Jul 25 '22 02:07 ildar170975

Do you want a custom card to keep somewhere an actual last-changed value for ALL entities? No, custom:logbook-card already does that by using data from recorder.

A card may only display/process some existing states/attributes. Since an object does not keep these "actual last-changed/updated" - there is nothing to display/process. I understand that.

What if an entity is excluded from Recorder? The onus is on the user to ensure history is recorded. If there's none then programming would display unavailable

Finally, I do not see any connection between multiple-entity-row and the Logbook. There currently is no connection but if you could incorporate the logic that custom:logbook-card uses to access recorder then this proposed new attribute logbook-last-changed couold display the most recent entry from recorder, or unavailailable if the routine could not find the entity in recorder.

Ideally, HA should preserve the last-changed (preferred) or last-updated (not sure how or when this ever differs from last-changed) across restarts but since it currently does not despite 2+ years of people requesting it, I was hoping it could somehow be pulled from recorder the way that custom:logbook-card does. Using that card does not fulfill my desire to have the correct last-changed value in entity rows in other cards such as yours.
I hope I am making myself clear. If you do not feel it is not do-able or is too much work then so be it. Thanks, Daniel.

danielbrunt57 avatar Jul 25 '22 16:07 danielbrunt57

No, custom:logbook-card already does that by using data from recorder.

Are you sure that actual last-changed/updated are stored in DB? Because AFAIK these data are NOT stored.

display the most recent entry from recorder

Currently ALL cards display the latest values of objects in DB. And Recorder keeps a historical data for objects which are assigned to be recorded.

ildar170975 avatar Jul 25 '22 18:07 ildar170975

No, custom:logbook-card already does that by using data from recorder.

Are you sure that actual last-changed/updated are stored in DB? Because AFAIK these data are NOT stored.

custom:logbook-card is NOT using HA's last-changed/last-updated. It is retrieving data from HA recorder/logbook. In my posted image I am specifying max-items: 1 to limit the list to just the newest entry.

image

display the most recent entry from recorder

Currently ALL cards display the latest values of objects in DB.

→ And Recorder keeps a historical data for objects which are assigned to be recorded ← That is what I am looking for.

danielbrunt57 avatar Jul 25 '22 18:07 danielbrunt57

It is retrieving data from HA recorder/logbook.

Recorder & Logbook are integrations using data from DB. If some info is not present in DB - no card can use it.

That is what I am looking for.

First you asked about "real" last-changed/updated values (i.e. displayed like "12 minutes ago", stored as timestamps) - then I explained you that these data are not present in DB. The last-changed/updated values - as you noticed - are not persistent and do not survive HA restart. There are methods to maintain these "real" last-changed/updated values; I only remember "save a current time in some input_datetime helpers on object change and then use them as last-changed/updated".

If you need to display the latest data of some entity - a state or attributes - then ALL cards like Entities, Entity, multiple-entity-row DO DISPLAY the LATEST data. They are taken from DB ("latest data"). Cards like history-graph take data from DB ("historical data") - if an entity is assigned for Recorder. Logbook card take data from DB ("historical data") - if an entity is assigned for Recorder and this entity has no UoM specified.

custom:logbook-card is NOT using HA's last-changed/last-updated. It is retrieving data from HA recorder/logbook. In my posted image I am specifying max-items: 1 to limit the list to just the newest entry.

The very same thing may be done by Entities card - it also displays the latest data.

Ideally, HA should preserve the last-changed (preferred) or last-updated (not sure how or when this ever differs from last-changed) across restarts but since it currently does not despite 2+ years of people requesting it, I was hoping it could somehow be pulled from recorder the way that custom:logbook-card does. Using that card does not fulfill my desire to have the correct last-changed value in entity rows in other cards such as yours.

The custom:logbook-card displays historical data from DB like a conventional Logbook card with some added improvements like "show an attribute, show last XXX records, replace a text for a state with smth, ...". It does not show anything which cannot be shown by other cards. It just adds some features for a user's convenience.

Also, please use ">" with some caution 'cause sometimes you are formatting your answers like quotes. There are must be an empty line between a quote and your answer.

ildar170975 avatar Jul 25 '22 19:07 ildar170975