Join us online for the Google Smart Home Developer Summit on October 21st! Register here to learn what's new, and what's coming up for Google Smart Home.

Smart Home LockUnlock Trait Schema

action.devices.traits.LockUnlock - This trait belongs to any devices that support locking and unlocking, and/or reporting a locked state.

Device ATTRIBUTES

None.

Device STATES

Devices with this trait may report the following states as part of the QUERY operation. To learn more about handling QUERY intents, see Intent fulfillment.

States Type Description
isLocked Boolean

Whether the device is currently locked.

isJammed Boolean

Whether the device is currently jammed and therefore its locked state cannot be determined.

Examples

Device that is locked

{
  "isLocked": true
}

Device that is jammed

{
  "isJammed": true
}

Device COMMANDS

Devices with this trait may respond to the following commands as part of the EXECUTE operation. To learn more about handling EXECUTE intents, see Intent fulfillment.

action.devices.commands.LockUnlock

Lock or unlock the device.

Parameters

Parameters Type Description
lock Boolean

Required.

True when command is to lock, false to unlock.

followUpToken String

Google-provided token for follow-up response.

Examples

Lock the front door.

{
  "command": "action.devices.commands.LockUnlock",
  "params": {
    "lock": true,
    "followUpToken": "123"
  }
}

Unlock the front door.

{
  "command": "action.devices.commands.LockUnlock",
  "params": {
    "lock": false,
    "followUpToken": "567"
  }
}

An error occurred locking or unlocking the device.

Supported values:

remoteSetDisabled
deviceJammingDetected
notSupported
alreadyLocked
alreadyUnlocked

Follow-up responses

Devices with this trait may return the following follow-up response payload as part of the EXECUTE operation. To learn more about implementing follow-up responses, see Notifications for smart home Actions.

The payload contains one of the following:

Success: Locked

Fields Type Description
followUpToken String

Required.

Token provided in the original EXECUTE request.

status String

Required.

Result of the request.

Supported values:

SUCCESS
isLocked Boolean

Required.

Indicates whether the device is locked.

Failure

Fields Type Description
followUpToken String

Required.

Token provided in the original EXECUTE request.

status String

Required.

Result of the request.

Supported values:

FAILURE
errorCode String

Required.

The value can be any error code for this trait, for example, deviceJammingDetected.

Examples

Lock the front door. (follow-up response for success case)

{
  "LockUnlock": {
    "priority": 0,
    "followUpResponse": {
      "status": "SUCCESS",
      "isLocked": true,
      "followUpToken": "1234"
    }
  }
}

Unlock the front door. (follow-up response for success case)

{
  "LockUnlock": {
    "priority": 0,
    "followUpResponse": {
      "status": "SUCCESS",
      "isLocked": false,
      "followUpToken": "1234"
    }
  }
}

Lock the front door. (follow-up response for failure case)

{
  "LockUnlock": {
    "priority": 0,
    "followUpResponse": {
      "status": "FAILURE",
      "errorCode": "deviceJammingDetected",
      "followUpToken": "1234"
    }
  }
}

Device ERRORS

See the full list of errors and exceptions.