Skip to content

Lock Mechanism

José Antonio Jiménez Campos edited this page May 9, 2021 · 43 revisions

A HomeKit Lock Mechanism.

Type Device Type
4 Lock Mechanism
44 Double Lock Mechanism (deprecated, will be replaced by a new system)

The following configuration is available for lock mechanisms:

Section Key Description
Actions "0", "1" etc. The actions performed by the accessory
Inching Time "i" Time period before returning first mechanism to previous state
Inching Time "i1" Time period before returning second mechanism to previous state (device type 44 only)
State & Status Inputs "f[n]" & "g[n]" Inputs that manage accessory state
ICMP Ping Inputs "q[n]" & "p[n]" Ping inputs that manage accessory state
Accessory Notifications "m" Notifications to send to another accessory
Initial State "s" State a lock accessory enters on boot
Actions on Boot "xa" Enable / Disable execution of accessory actions on boot

Example of single lock mechanism

{
  "a":[{
    "t":4,
    "i":3,
    "0":{"r":[{"g":4,"v":1,"i":0.5}]},
    "1":{"r":[{"g":4}]},
    "b":[{"g":5,"p":0,"i":1,"t":0}]
  }]
}

This is an example of a lock mechanism with an external push button ("t":4). The inching time of the accessory is set to 3 seconds ("i":3), causing the accessory to automatically re-lock, 3 seconds after being unlocked. The lock mechanism is controlled using GPIO 4. The external push button is connected to GPIO 5. With no pull-up ("p":0), inverted input ("i":1) and single press that is opposite to the default ("t":0`).

Example of double lock mechanism

{
  "c":{"o":4,"b":[{"g":0,"t":3}]},
  "a":[{
    "t":44,
    "i":3,
    "i1":10,
    "0":{"r":[{"g":4,"v":1,"i":0.5}]},
    "1":{"r":[{"g":4}]},
    "2":{"r":[{"g":12,"v":1,"i":0.5}]},
    "3":{"r":[{"g":12}]}
  },{
    "t":1,
    "0":{"m":[{"g":1,"v":0}]},
    "1":{"m":[{"g":1,"v":1}]}
  },{
    "t":1,
    "0":{"m":[{"g":1,"v":2}]},
    "1":{"m":[{"g":1,"v":3}]}
  }]
}

This is an example of a double lock mechanism (accessory 1) controlled from two HomeKit switches (accessories 2 & 3). The inching time of the first lock is set to 3 seconds ("i":3), causing the accessory to automatically re-lock, 3 seconds after being unlocked. The inching time of the second lock is set to 10 seconds ("i1":10), causing the second lock to automatically re-lock, 10 seconds after being unlocked.

The first lock mechanism is controlled using GPIO 4 & the second is controlled by GPIO 12.

Both lock mechanisms can be locked & unlocked by HomeKit switches (accessories 2 & 3).

Actions

A lock mechanism has the following actions.

Key Action Description
"0" UNLOCK Unlock the mechanism (default)
"1" LOCK Lock the mechanism
"2" UNLOCK Unlock the second mechanism (device type 44 only)
"3" LOCK Lock the second mechanism (device type 44 only)

The Digital Outputs "r": [{}] for each should be configured to attain the desired state.

Accessory Notifications

The list of notifications "m" supported by a lock mechanism are as follows:

Value Notification
"0" UNLOCK
"1" LOCK
"2" UNLOCK
"3" LOCK

Accessory notifications can be included as part of an action definition. When an action occurs any one of the above notifications can be sent to another accessory using the "m" option within the action object.

See the general Accessory Notifications section for details of how to configure these notifications.

State and Status Inputs

State inputs "f[n]" & Status Inputs "g[n]" are supported by this accessory. The supported list is:

Key Action
"f0" Perform action "0" (Unlock)
"f1" Perform action "1" (Lock)
"g0" Set accessory state to Unlock
"g1" Set accessory state to Lock

Refer to State Inputs for more detail and examples.

ICMP Ping Inputs

ICMP Ping inputs "p[n]" and "q[n]" are supported by this accessory. The supported list is:

Key Action
"p0" Perform action "0" (Unlock)
"p1" Perform action "1" (Lock)
"q0" Set accessory state to Unlock
"q1" Set accessory state to Lock

Refer to ICMP Ping Inputs for more detail.

Initial State

The Initial State key is supported by this accessory. Refer to Initial State for more details.

Key State Description
"s" 0 UNLOCKED
1 LOCKED (default)
4 Defined by fixed state inputs
5 Last state before restart
6 Opposite to last state before restart
Clone this wiki locally