Tracking of lock entry

Perhaps a job for a trigger-based template sensor. You can store pretty much anything in the attributes of a template sensor. And a trigger-based template sensor keeps it state and attributes across restarts.
Here’s an example I put together with what I learned from @123 from this post and this post. This will create an attribute called “log” which has the last 10 events and captures the pertinent data I extracted from my own Kwikset 888 lock. You will have to change the parameters to suit your device.

  - trigger:
      - platform: event
        event_type: zwave_js_notification
        event_data:
          device_id: your_device_id_goes_here
          label: Access Control
    sensor:
      - name: "Front Door Lock Event"
        state: "{{now() | as_local }}"
        unique_id: front_door_lock_event
        attributes:
          log: >
            {% set log = this.attributes.get('log', []) %}
            {% if trigger.event.data.parameters.userId is defined %}
              {% set user = trigger.event.data.parameters.userId %}
            {% else %}
              {% set user = 'None' %}
            {% endif %}
            {% if trigger.event.data.event_label is defined %}
              {% set new = [{
                  "event": trigger.event.data.event_label,
                  "user": user,
                  "time": (trigger.event.time_fired | as_local).strftime('%Y-%m-%dT%H:%M:%S%z') }] %}
              {% set log = new + log %}
            {% endif %}
            {% if 0 <= 10 < log|count %}
              {% set log = log | rejectattr('time', 'eq', log[10].time) | list %}
            {% endif %}
            {{ log }}
1 Like