History logbook for template sensor

Hi,
I’m new to HA, just started a few weeks back, all good so far except I can’t seem to work out how to easily see logbook history for a custom template sensor I created for a yale z-wave door lock to see who locked/unlocked the door.

What I’ve done:
1.Yale z-wave lock via Z-Wave JS
2. Template sensor code in configuration.yaml, so I can translate the yale alarm_type and alarm_level values (see code below)

When clicking on the original door lock entity on a dashboard (shown left below), I get a history tab and can see logbook entries:

But when I click on my custom template sensor, there is no History tab (shown on right above), and I can’t see any logbook entries showing who previously locked/unlocked door:

Is it possible to show logbook history for this template, so when in the HA app I can tap on this entity, and easily see history?

Or do I have to add a separate logbook card to the dashboard to show history?

Thanks in advance.

Template code:

template:
  - sensor:
    - name: "Front Door Status"
      unique_id: front_door_status
      state: >-
        {%- if is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "19") -%}
            {%- if is_state("sensor.real_living_touchscreen_deadbolt_alarm_level_frontdoor", "0") -%}
              Unlocked (Master)
            {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_level_frontdoor", "1") -%}
              Unlocked (User 1)
            {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_level_frontdoor", "2") -%}
              Unlocked (User 2)
            {%- else -%}
              Unlocked by User {{ sensor.real_living_touchscreen_deadbolt_alarm_level_frontdoor }}
            {%- endif %}
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "27") %}
            Auto-Relocked
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "21") %}
            Locked (Manual)
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "22") %}
            Unlocked (Manual)
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "24") %}
            Locked (Remote)
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "25") %}
            Unlocked (Remote)
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "161") %}
            Tampered!
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "154") %}
            Locked
          {%- else -%}
            Unknown Level {{ states.sensor.real_living_touchscreen_deadbolt_alarm_level_frontdoor.state }} Type {{ states.sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor.state }}
          {%- endif %}
      attributes:
        alarm_type: "{{ states.sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor.state }}"
        alarm_level: "{{ states.sensor.real_living_touchscreen_deadbolt_alarm_level_frontdoor.state }}"
      icon: >-
        {%- if is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "19") -%}
            mdi:lock-open-outline
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "21") %}
            mdi:lock-outline
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "24") %}
            mdi:lock-outline
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "27") %}
            mdi:lock-outline
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "154") %}
            mdi:lock-outline
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "22") %}
            mdi:lock-open-outline
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "25") %}
            mdi:lock-open-outline
          {%- elif is_state("sensor.real_living_touchscreen_deadbolt_alarm_type_frontdoor", "161") %}
            mdi:alert
          {%- else -%}
            mdi:lock-open
          {%- endif %}
1 Like

Sensor entity more info pop-up cards do not include the logbook or history tab. If you want that make it a template lock instead of a template sensor.

Sensor entities with units are excluded from the logbook as it is assumed they will update frequently and flood the logbook with value changes.

It seems that rather than create two more-info pop-up cards for sensors, one for sensors with units and one for sensors without units, the devs have opted just to create one pop-up that does not have the logbook or history tab.

I too am having this issue, but it’s more complicated than just saying I need to change to a different type of entity. I have a sensor entity that can be in one of 6 different states, but it’s impossible to read on that little bar graph when it changes to one of them for only 10 seconds, the logbook format in the card would be perfect, but I can’t figure out how to display the information that way.
Home Assistant obviously is already storing this data, otherwise it couldn’t show it in bar form, so I don’t buy the “flood the logbook” excuse. There’s got to be a way to present this data to the end user in a usable way.

Flooding the logbook display page. Not the database.

And yet it happily floods the log book with state changes for binary sensors without blinking, even though they would present perfectly well on the bar chart visualization because seeing that there is a change is enough, you don’t need to be able to read what it was because there are only two states. But as soon as you have something with more than two states, and it’s actually important to be able to see what they are, you no longer have the ability because they take away the logbook.
The guesswork that home assistant does to decide how you want to visualize your data is more often wrong than right, and yet there doesn’t seem to be any way to customize it.

Now imagine what that would be like with every minute sensor change for all numeric sensors.

There are numerous ways to do this. e.g. Check out browser-mod, you can replace the pop-ups with whatever you want.

I said nothing at any point about numeric sensors. How about for sensors of class enum?

1 Like

No, but you replied to my post where I did.

I’ve also now completely disproved your point anyway. When I check the actual logbook, it DOES have the entity in question, and it shows properly, it’s just that the history tab when clicking on the entity doesn’t include it.
So it’s obviously nothing to do with avoiding spamming the logbook.

So why not show it when clicking the entity?

1 Like

Well you have a system different to everyone else.

https://www.home-assistant.io/integrations/logbook/

And you are ignoring what I said earlier.

Also don’t shoot the messenger. I’m just telling you why I think this is happening. I did not make any comment on the reasonableness of that decision.

Once again, I’m not talking about anything with units. I made that clear previously, and yet you keep going back to it.
I specified my use case was a non-numeric sensor entity with 6 possible states.

Anything classed as a “sensor” does not show logbook when you click on the entity.

1 Like

And yet again you are ignoring what I wrote. Read it:

Yes, I know that.
That’s why I’m posting in the first place. Telling me what I already know isn’t helpful.

1 Like

Sorry, but you could not distinguish between the logbook and the recorder, so I very much doubted you knew why this occurs.

Feel free to create a pull request to change the more info pop-up, or if that is not within your skills create a frontend feature request here: home-assistant/frontend · Discussions · GitHub

I don’t know where you thought I was confused between the logbook and the recorder? I have never had any problem distinguishing the 2.

And after you posted your non-sensical “it’s not there so it doesn’t flood the logbook”,
I pointed out that it was YOU who didn’t understand because the logbook itself contains the information on non-numeric sensors.

But I’m done with you now. I won’t be replying further. It’s obvious you want to blame me instead of admit that the way home assistant presents this is non-sensical.

Blame the user, it’s the open source way!

Maybe in future try to be CONSTRUCTIVE instead of just belittling people for pointing out the flaws.

No need to get upset. I told you the ways forward with this: