## Remote Lock/Unlock

### Execute Lock/Unlock

Flowchart

```mermaid
graph TD;
id(Execute Operation)
id1{Is Lock State Open}
id2(Unlock openDoor)
id3(Lock closeDoor)
id4{Unlock Result}
id5{Lock Result}
id6(Unlock Success)
id7(Lock Success)
id8(Show Error)
id --> id1
id1-->|Yes|id2
id1-->|No|id3
id2 --> id4
id3 --> id5
id4-->|Yes|id6
id4-->|No|id8
id5-->|Yes|id7
id5-->|No|id8
```

Description

> - To determine whether the lock is locked, you need to get the value of the lock state dp47(lock_motor_state) to judge. If the value is true, it means the door is open, otherwise it is closed.
> - If the lock/unlock operation fails, you need to display a prompt message according to the error code
> - The lock/unlock API fully validates whether the current `Remote Lock/Unlock Function Switch` is enabled, whether the current device is online, whether the current user has remote lock/unlock permissions, etc.

### Remote Lock/Unlock Function Switch

- Default is enabled, i.e., supports remote lock/unlock functionality
- Users can configure the switch

### Remote Lock/Unlock Permissions

- Supported permissions include: `Only administrators can lock/unlock`, `Everyone can lock/unlock`, `No one can lock/unlock`
- Default remote lock/unlock permission is: `Everyone can lock/unlock`

### API

#### Check Remote Lock/Unlock Function Switch Status

- Meaning: Confirm whether the current remote lock/unlock function is available
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/open/checkRemoteEnabled)

#### Unlock

- Meaning: Send remote unlock command
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/open/openDoor)

#### Lock

- Meaning: Send remote lock command
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/open/closeDoor)

#### Set Function Enable or Disable

- Meaning: Enable or disable remote lock/unlock function
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/open/remoteEnabled)

#### Get Current Remote Lock/Unlock Permission

- Meaning: Get the current user's remote lock/unlock permission
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/open/getRemotePermission)

#### Get Permission List

- Meaning: Get the permission list for remote lock/unlock
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/open/getRemotePermissionList)

#### Configure Permission

- Meaning: Set remote lock/unlock permission
- Details: [View Documentation](/en/miniapp/develop/ray/api/doorlock/open/updateRemotePermission)
