-
-
Notifications
You must be signed in to change notification settings - Fork 18
Zigbee2MQTT integration
Lock Code Manager supports Zigbee locks running Zigbee2MQTT via the MQTT integration.
Zigbee2MQTT exposes lock PIN codes through MQTT topics. Lock Code Manager communicates with the lock by publishing and subscribing to these topics using the Home Assistant MQTT integration. Each lock is identified by its Zigbee2MQTT friendly name, which is resolved from the device registry.
PIN codes are readable on most Zigbee locks — the lock reports both occupancy and the actual PIN value. However, some models or firmware versions may mask PINs depending on the expose_pin setting in Zigbee2MQTT.
- Zigbee2MQTT running and connected to Home Assistant via the MQTT integration
- A Zigbee lock that supports PIN codes (e.g., Yale, Kwikset, or similar models with the DoorLock cluster)
- The lock entity must appear as
lock.*from themqttintegration in Home Assistant
| Operation | Supported | Notes |
|---|---|---|
| Set PIN | ✅ | Via MQTT publish to zigbee2mqtt/<friendly_name>/set
|
| Clear PIN | ✅ | Via MQTT publish to zigbee2mqtt/<friendly_name>/set
|
| Read PIN | Depends | Available when expose_pin is enabled in Zigbee2MQTT; otherwise occupancy-only |
| Push updates | ✅ | Via MQTT subscription to zigbee2mqtt/<friendly_name>
|
| Code slot events | Yes | Via lock/unlock actions with user identification |
Lock Code Manager subscribes to the lock's MQTT topic and receives real-time updates when:
- A PIN code is added, modified, or cleared on the lock
- The lock reports its current user/PIN state
This means changes made at the lock keypad, via the Zigbee2MQTT frontend, or through other tools are detected quickly without waiting for the next poll.
Polling still occurs as a fallback (every 5 minutes) and a hard refresh runs every hour to catch any missed updates.
Lock Code Manager uses the standard Zigbee2MQTT topic layout:
-
Subscribe:
zigbee2mqtt/<friendly_name>— receives state updates includingusersandpin_codedata -
Get:
zigbee2mqtt/<friendly_name>/get— requests current PIN state for individual slots -
Set:
zigbee2mqtt/<friendly_name>/set— sets or clears PIN codes
The base topic (zigbee2mqtt) is auto-detected from the device registry. Custom base topics are supported.
- Optimistic updates: After setting a PIN, Lock Code Manager optimistically assumes success. MQTT QoS 0 does not guarantee delivery, so if the message is lost, the actual state may diverge until the next hard refresh (up to 1 hour). This is the same pattern used by other push-based providers.
- Code slot events: Lock/unlock actions with PIN identification are mapped to Lock Code Manager events via MQTT action messages.
-
expose_pinsetting: Ifexpose_pinis disabled in Zigbee2MQTT (the default on some lock models), the lock only reports whether a slot is occupied, not the actual PIN value. Lock Code Manager treats unreadable PINs asUNREADABLE_CODEand re-sets them on restart to guarantee correctness. - Sequential slot queries: PIN codes are fetched one slot at a time to avoid overwhelming the Zigbee mesh. This is slower than parallel queries but more reliable.
-
Timeout handling: If a slot query times out (10 seconds), the slot is reported as
UNREADABLE_CODErather than empty, preventing unnecessary re-programming.
Some lock models have expose_pin disabled by default. To enable it:
- Open the Zigbee2MQTT frontend
- Navigate to your lock device
- Go to the Settings (specific) tab
- Enable Expose pin
When expose_pin is enabled, Lock Code Manager can read back the actual PIN values and verify they match the configured PINs. When disabled, it relies on occupancy status and optimistic updates.
Zigbee2MQTT lock support is new. The following locks have been tested:
- Yale YMF40A with Zigbee module
If you have tested Lock Code Manager with a specific Zigbee lock, please open an issue or PR to add it to this list.
Ensure the MQTT integration is loaded and the lock entity appears in Home Assistant as lock.* from the mqtt platform. Lock Code Manager identifies Zigbee2MQTT devices by their device registry identifiers (must contain zigbee2mqtt_*).
Lock Code Manager could not resolve the Zigbee2MQTT friendly name from the device registry. Ensure the lock has a device entry with a name that matches its Zigbee2MQTT friendly name.
- Check that the MQTT integration is connected (Settings > Integrations > MQTT)
- Verify the lock is online in the Zigbee2MQTT frontend
- Check Home Assistant logs for MQTT publish/subscribe errors
- If PINs show as "unreadable", enable
expose_pinin Zigbee2MQTT settings
Zigbee mesh congestion or a sleeping end device can cause timeouts. Lock Code Manager will retry on the next poll cycle. If timeouts are frequent, check your Zigbee mesh quality and ensure the lock has good signal strength.
Getting Started
UI
- Add a UI for lock code management — overview & decision guide
- UI Strategies
- Custom Cards
Features
- Managing Guests and Rentals
- Services and Actions
- Blueprints
- Tracking lock state change events
- Using Condition Entities
- Unsupported Condition Entities
- Notifications
Advanced
Development
Troubleshooting
FAQ
Supported Integrations