public enum LockState

  1. Object
  2. Enum<LockState>
  3. LockState

ImplementsComparable<LockState>

The state of a door lock, for Trait.LOCK_STATE and Trait.TARGET_LOCK_STATE.

Only SECURED and UNSECURED may be written; the rest describe situations an accessory reports and a caller cannot ask for.

Enum constants

SECUREDLocked.
UNSECUREDUnlocked.
PARTIALLY_LOCKEDThe bolt is partly thrown: not locked, and not simply open either.
JAMMEDThe mechanism is stuck.
UNKNOWNThe accessory could not say.

Methods

public static LockState[] values()
public static LockState valueOf(String name)
public static LockState of(TraitValue value)Reads a lock state out of a trait value, total: a value that is not an enum, or whose ordinal is outside this set, answers UNKNOWN.
public boolean isWritable()Whether this state may be written to Trait.TARGET_LOCK_STATE.

Inherited methods

Enum constant details

SECURED

SECURED

Locked.

Maps to HomeKit’s secured and Matter’s Locked.

UNSECURED

UNSECURED

Unlocked.

Maps to HomeKit’s unsecured and to both of Matter’s Unlocked and Unlatched – the latter is a 1.4 addition meaning the latch has been pulled back as well as the bolt, which HomeKit has no way to say.

PARTIALLY_LOCKED

PARTIALLY_LOCKED

The bolt is partly thrown: not locked, and not simply open either.

Matter’s NotFullyLocked. Its own constant rather than being folded into a neighbour, because both alternatives lose real information – calling it JAMMED asserts a fault that may not exist, and calling it UNKNOWN throws away a state the accessory was specific about.

HomeKit never produces this.

JAMMED

JAMMED

The mechanism is stuck.

Unreachable outside HomeKit. HomeKit publishes a jam as a value of the lock characteristic, so it arrives here. Matter reports it as a LockOperationError or DoorLockAlarm event, and this release does not claim Matter events – so a jammed Matter lock reports PARTIALLY_LOCKED or UNKNOWN instead. Do not build a safety feature on this constant.

UNKNOWN

UNKNOWN
The accessory could not say. Also what a nullable Matter LockState resolves to when it is null.

Method details

values

public static LockState[] values()

valueOf

public static LockState valueOf(String name)

of

public static LockState of(TraitValue value)
Reads a lock state out of a trait value, total: a value that is not an enum, or whose ordinal is outside this set, answers UNKNOWN.

Parameters

value TraitValue
a value read from Trait.LOCK_STATE or Trait.TARGET_LOCK_STATE, or null

Returns

the state, never null

isWritable

public boolean isWritable()
Whether this state may be written to Trait.TARGET_LOCK_STATE.

Returns

true for SECURED and UNSECURED only