Set a Matter lock credential
Use this action to add or update a credential on a Matter lock. A credential is what a user presents to unlock the lock, such as a PIN code or an RFID tag. A common use is to give a houseguest their own PIN code.
If you leave the credential index empty, the lock automatically assigns the next available slot. If you leave the user index empty, the lock creates a new user for the credential.
This action returns its result in a response variable, which you can use in later steps of the same automation or script.
Using this action from the user interface
If you prefer building automations and scripts visually, Home Assistant walks you through this action step by step. You pick what to target, tweak a few options, and save. No YAML knowledge required.
To set a lock credential from an automation or a script:
- Go to Settings > Automations & scenes.
- Open an existing automation or script, or select Create automation > Create new automation.
- If you’re setting up a new automation, add a trigger in the When section. Scripts don’t need a trigger. They run when something else calls them.
- In the Then do section, select Add action.
- Select what you want to control. Under By target (see Targets), select the lock you want to manage.
- From the actions shown for that target, select Set a Matter lock credential.
- Set the Credential type and Credential data, and any other details you want.
- Select Save.
Options in the UI
The type of credential to set, such as a PIN or an RFID tag. See the list of credential types below.
The credential value to store. For a PIN, use digits only, such as 1234. For RFID, use a hexadecimal string, such as AABBCCDD.
The credential slot index (0-based). Leave empty to let the lock find an available slot.
The user (1-based) to link the credential to. Leave empty to have the lock create a new user.
The status to set when creating a new user for this credential, either occupied and enabled or occupied and disabled.
The available credential types are:
-
pin: A numeric PIN code entered on the lock’s keypad. -
rfid: An RFID tag or card tapped against the lock’s reader. -
fingerprint: A fingerprint registered on the lock’s biometric sensor. -
finger_vein: A finger-vein pattern registered on the lock’s biometric sensor. -
face: A facial recognition profile registered on the lock.
Using this action in YAML
If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.
In YAML, refer to this action as matter.set_lock_credential. To add a PIN to an existing user, store the result in a response variable:
action: matter.set_lock_credential
target:
entity_id: lock.front_door
data:
credential_type: pin
credential_data: "1234"
user_index: 1
response_variable: result
To add an RFID tag and let the lock create a new user:
action: matter.set_lock_credential
target:
entity_id: lock.front_door
data:
credential_type: rfid
credential_data: "AABBCCDD"
response_variable: result
Options in YAML
The type of credential to set: pin, rfid, fingerprint, finger_vein, or face.
The credential value to store. For pin, use digits only, such as 1234. For rfid, use a hexadecimal string, such as AABBCCDD.
The credential slot index (0-based). Omit this field to let the lock find an available slot.
The user index (1-based) to link the credential to. Omit this field to have the lock create a new user.
The status to set when creating a new user for this credential: occupied_enabled or occupied_disabled.
The type of user to set when creating a new user for this credential. See the user types on the Set a Matter lock user action.
Targets of the action
This action requires a target. The target is the object of the action. You can point the action at a single entityAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more], a device, an area, a floor, or a label, and Home Assistant will run the action on every matching matter entity behind that target.
-
Entity: one specific matter entity, such as
matter.living_room. - Device: every matter entity that belongs to a device.
- Area: every matter entity in a room or area.
- Floor: every matter entity on a floor.
- Label: every matter entity that shares a label.
You can also select different target types in one action. For example, you can add a specific entity and an area as targets in the same action to run the action on both of them at once.
Response data
The action returns where the credential was stored. The response includes the following fields:
-
credential_index: The slot index where the credential was stored. -
user_index: The user the credential is linked to. -
next_credential_index: The next available credential slot, if the lock reports one.
Good to know
- A credential is always linked to a user. If you do not provide a user index, the lock creates a new user for the credential.
- The lock never returns the credential value you stored. Keep a record of PIN codes somewhere safe if you need them later.
Still stuck?
The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the action you’re calling and what you expected to happen, or share on our subreddit /r/homeassistant.
AI assistants like ChatGPT or Claude can also explain actions or suggest the right one when you describe what you want in plain language.
Related actions
These actions work well alongside this one:
-
Clear a Matter lock credential: Removes a credential, such as a PIN, from a Matter lock.
-
Get Matter lock credential status: Returns the status of a credential slot on a Matter lock.
-
Set a Matter lock user: Creates or updates a user on a Matter lock.