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 %}