Get PIN codes
Use this action to retrieve all PIN codes stored on a Schlage lock. For example, you can use it to check which codes are set before adding or removing one.
This action returns its result as response data and does not change anything on the lock.
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 get the PIN codes 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 Schlage lock.
- From the actions shown for that target, under Schlage, select Get PIN codes.
- Select Save.
Options in the UI
This action has no additional options beyond the target.
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. For how an automation or a script is built in YAML, refer to Automations in YAML and Scripts.
In YAML, refer to this action as schlage.get_codes. A basic example looks like this:
action: schlage.get_codes
target:
entity_id: lock.front_door
response_variable: codes
This stores the PIN codes of lock.front_door in a variable named codes.
Options in YAML
This action has no additional YAML options beyond the target.
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 lock entity behind that target.
-
Entity: one specific lock entity, such as
lock.living_room. - Device: every lock entity that belongs to a device.
- Area: every lock entity in a room or area.
- Floor: every lock entity on a floor.
- Label: every lock 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.
To learn which entities Home Assistant includes for a device, area, floor, or label, and how it handles several entities, refer to Automation targets.
To leave out some of these entities, refer to Excluding targets. For example, you can leave out one lock entity in an area.
Response data
The action returns the result for each targeted lock, keyed by entity ID. For each lock, it returns a mapping of the stored codes, keyed by a unique code identifier. Each code has the following fields:
- name: The name of the PIN code.
- code: The PIN value.
- access_code_id: A unique access code identifier.
-
schedule: The schedule for this PIN, or
nullfor permanent PINs.
lock.front_door:
93ab517c-0000-0000-0000-000000000000:
name: Example Person
code: "3333"
access_code_id: "93ab517c-0000-0000-0000-000000000000"
schedule: null
82958b77-0000-0000-0000-000000000000:
name: Guest
code: "1234"
access_code_id: "82958b77-0000-0000-0000-000000000000"
schedule:
type: temporary
start_datetime: "2026-09-01T15:00:00+00:00"
end_datetime: "2026-09-01T16:00:00+00:00"
Schedule formats
The schedule field describes when a PIN is active. It is null for permanent PINs, or one of the following shapes:
Temporary: set via the start_datetime and end_datetime fields:
{
"type": "temporary",
"start_datetime": "2026-09-01T15:00:00+00:00",
"end_datetime": "2026-09-01T16:00:00+00:00"
}
Recurring: a single recurring schedule set through the Schlage app:
{
"type": "recurring",
"days_of_week": {
"sun": false,
"mon": true,
"tue": true,
"wed": true,
"thu": true,
"fri": true,
"sat": false
},
"start_time": "08:00:00",
"end_time": "17:00:00"
}
A recurring schedule has the following fields:
- days_of_week: One boolean per day of the week, indicating whether the schedule is active on that day.
-
start_time: The time of day the schedule starts, as a string in
HH:MM:SSformat. -
end_time: The time of day the schedule ends, as a string in
HH:MM:SSformat.
Multi-recurring: two time windows, also set through the Schlage app:
{
"type": "multi_recurring",
"windows": [
{
"days_of_week": {
"sun": false,
"mon": true,
"tue": true,
"wed": true,
"thu": true,
"fri": true,
"sat": false
},
"start_time": "08:00:00",
"end_time": "12:00:00"
},
{
"days_of_week": {
"sun": false,
"mon": true,
"tue": true,
"wed": true,
"thu": true,
"fri": true,
"sat": false
},
"start_time": "13:00:00",
"end_time": "17:00:00"
}
]
}
Each window in a multi_recurring schedule uses the same fields as a recurring schedule.
Recurring and multi_recurring schedules are configured through the Schlage app and cannot be set through Home Assistant service actions.
Try it yourself
Ready to test this? Open Settings > Tools > Actions, search for this action, fill in the fields, and select Perform action. You see what happens on your actual entitiesAn 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] without writing a line of YAML.
Still stuck?
To test the action on its own, run it in the automation editor with Run action, and check the message that it shows. To see what the action did when the automation ran, open the trace of that run. For details, refer to Testing automations. For common problems and their solutions, refer to Troubleshooting automations.
If that doesn’t help, 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
Explore related actions:
-
Add PIN code: Adds a PIN code to a Schlage lock.
-
Delete PIN code: Deletes a PIN code from a Schlage lock.