Skip to content

(Advanced) Create your own automations based on lock state changes

Raman Gupta edited this page Feb 12, 2021 · 4 revisions

Are you interested in creating automations when your lock state changes from locked to unlocked? We try to provide some good defaults out of the box, but in case these don't meet your needs, feel free to build your own! You will want to use an event trigger for the keymaster_lock_state_changed event. We fire this every time the lock state changes and we can detect a lock action (e.g. action_text). The format of the event is as follows:

{
  "lockname": "frontdoor",
  "entity_id": "lock.front_door_lock",
  "state": "locked",
  "action_text": "Keypad Lock",
  "code_slot": 1,
  "code_slot_name": "Jack"
}

You can access these parameters in your conditions and actions for the automation by by using trigger templates. For example, to use the name that's entered into the code slot that triggered the event, use {{ trigger.event.data.code_slot_name }}.