Logbook output in the UI, only one line possible?

Currently the activity card/logbook shows this (with some spacing as well):

Blackbird P80 heat pump changed to Heating
07:19:54 - 17 minutes ago
Blackbird P80 heat pump became unavailable
07:11:28 - 25 minutes ago
Blackbird P80 heat pump changed to Heating
07:03:20 - 33 minutes ago

Is there a way to only show this (single line, only time and state, ideally without spacing):

07:19:54 Heating
07:11:28 Unavailable
07:03:20 Heating

If you have a sensor for the log entries, then a markdown card can do pretty much what you desire.

Consider a custom logbook card, very customizable.

I checked out the Markdown card, took the 10 minute course, but there are no examples of how to integrate text with the state of that specific sensor which is listed in the activity card/lobook.
What am I missing?

For that method, you need to create a special template sensor which will store a history (like β€œ100 last changes”) in an attribute (representing a list of entries β€œvalue, time”) of your needed entity.
Then you may print a list of these entries in Markdown.
Sorry , cannot give you right now an example of this template sensor.
This is a very interesting method which you better to learn. Meanwhile you may try that custom card I suggested.

Thanks, I looked at this:

which for me seemed close to custom card.
However, looking at the code and the output, there is always a second line which I cannot map to the code, how can I get rid of that.

I like your idea about the list but sadly don’t know how to populate that list of 100 last changes. Printing that list would be the next challenge since I don’t see examples in Markdown for that.
I’ll look a bit further based on your answer. Thanks!

Well, some progress
I’ve got an entity state on a markdown card.

type: markdown
content: |
  ### P80 states
  **{{ states('sensor.sn_xxxx_xxxx') }}**

Next step is to get the last 100 or so, will also try to add the time on each line.

I agree, thanks!

I do not understand this sentence (.
Try this short example:

type: custom:logbook-card
entity: sun.sun
date_format: dd/MM/YYYY hh:mm
show:
  start_date: true
  end_date: false
  duration: false

You can even move that β€œstart_date” label to the right:

type: custom:mod-card
card:
  type: custom:logbook-card
  entity: sun.sun
  date_format: dd/MM/YYYY hh:mm
  show:
    start_date: true
    end_date: false
    duration: false
  card_mod:
    style: |
      .item-content {
        display: flex;
        justify-content: space-between;
      }

P.S. For those who use card-mod - adding β€œmod-card” here is a quick way to make this card-mod style working. In card-mod 3.x this logbook-card worked fine w/o that β€œmod-card” thing, was broken in card-mod 4.0.0.

1 Like

Another educational example (still w/o that special template sensor):

type: markdown
content: |-
  {% for LIGHT in states.light -%}
    {{state_attr(LIGHT.entity_id,'friendly_name')}}: {{state_translated(LIGHT.entity_id)}} (since {{as_timestamp(LIGHT.last_changed) | timestamp_custom('%d/%m/%y %H:%M:%S')}})
  {% endfor %}

Or even in a table form:

type: markdown
content: |-
  | name | state | since |
  -|-|-
  {% for LIGHT in states.light -%}
    | {{state_attr(LIGHT.entity_id,'friendly_name')}} | {{state_translated(LIGHT.entity_id)}} |{{as_timestamp(LIGHT.last_changed) | timestamp_custom('%d/%m/%y %H:%M:%S')}} |
  {% endfor %}

1 Like


This is what I see in the activity card, which I stated in the original post but in text version only.

Well, that custom logbook-card allows to choose what to show.

When pasting this yaml I get a Configuration Error.
I know the mod-card is working, I changed the color of another manual card I made.

I think I don’t have the custom:logbook-card configured correctly, instruction says:
Configure Lovelace to load the card:

resources:
  - url: /local/logbook-card.js?v=1
    type: module

But don’t know in which file this needs to go, tried configuration but that is not correct.

First, try w/o card-mod, use that simple version:

type: custom:logbook-card
entity: sun.sun
date_format: dd/MM/YYYY hh:mm
show:
  start_date: true
  end_date: false
  duration: false

Make sure that logbook-card is properly installed.
I use HACS to install custom cards, so I do not need to care about that β€œresources” line.
If you prefer not to use HACS - then make sure that this β€œxxx.js” file is placed into β€œwww” folder (since you use a β€œ/local/xxx.js” path, here β€œlocal” stands for β€œwww”).

Testing a version with card-mod is another step.
First make this card working w/o card-mod.

These lines should be added into β€œconfiguration.yaml”:

lovelace:
  resources:
    - url: /local/my-custom-card.js
      type: module

Managed to find this info in Docs, a 1-2 years ago Docs became to hard to navigate in…

So, probably you need to try HACS, could be a simpler way for you…

After a lot of changes and restarts… :slight_smile:


I would like to see the last 24 hours, sorted back in time, most recent on top.
I played around a bit with the show parameters but did not get what I want.
And lose the icon, tried a few options with icon: none, but nothing worked.

Use β€œhistory” option (measured in days):

Either set an empty icon (1st screenshot - with β€œmdi:card” for clarity):


Or use a native β€œshow::icon” option:

Dumb mistake, had the date format typed wrongly, data was recent and sorted ok.
Icon space is now gone as well, great!

Thanks very much!

Congratulations.
But still suggest to learn how to keep a history in a template sensor, might be very useful in some cases.

Yes for later, I did have some progress on that but did not succeed.
Very happy with this result!