Here’s a working automation using the lock information you gave me. This has an extra condition that it will only fire if the keymaster event is for an unlock.
alias: 0 - Lock Logging
description: ''
trigger:
- platform: event
event_type: keymaster_lock_state_changed
event_data:
state: unlocked
variables:
sn: >-
{%- if trigger.event.data.code_slot_name == "" -%}
Manual
{%- else -%}
{{ trigger.event.data.code_slot_name }}
{%- endif -%}
verb: >-
{%- if trigger.event.data.code_slot_name == "" -%}
unlock of
{%- else -%}
unlocked
{%- endif -%}
door: >-
{%- if trigger.event.data.lockname == "front_door" -%}
Front Door
{%- elif trigger.event.data.lockanme == "back_door" -%}
Back Door
{%- else -%}
Garage Entry Door
{%- endif -%}
condition: []
action:
- service: logbook.log
data:
name: '{{ trigger.event.data.lockname }}'
entity_id: '{{ trigger.event.data.entity_id }}'
message: '{{ sn }} {{ verb }} the {{ door }}'
- service: notify.tykes_notices
data:
title: '{{ door }}'
message: '{{ sn }} {{ verb }} the {{ door }}'
data:
tag: '{{ door }}'
mode: single
This also sends to my tykes_notices notification group (phone, email, and web browser)
Since there is a data tag tied to the door, that means each time it happens, if you haven’t seen the notification it will get overwritten by the new notice. If you don’t want that, just remove the data tag section, or use a unique tag such as repeating the message. That way you would only have the latest notice of any specific type of unlock event.