createSDK

Requires:
@ray-js/lock-sdk≥1.2.0

Method signature
createSDK(options?: )

Description

Create an independent SDK instance for the specified device (recommended for multi‑device scenarios).

Parameters

ParameterTypeRequiredDescription
NoOptions; kind: 'fit' creates an accessory instance, default is lock.

Return Value

Type: Promise<LockSDKInstance>
SDK instance (lock or accessory, depending on kind)

Referenced Types

typeLockSDKInstanceSDK instance type (shared by locks and accessories). `destroy`/`updateConfig` are instance-scoped closures; others are exposed at the package top level.
PropertyTypeDescription
destroy() => voidDestroy the current instance: unregister the device Runtime, clear in-memory state and listeners (accessory instances also release passthrough report listeners).
(options: ) => voidUpdate the runtime configuration for the current instance (applies only to this instance’s device).
getCloudServiceStatus() => Promise<CloudServiceStatus>Get cloud storage service status (purchased or not / remaining days, etc.)
getServicePopupList() => Promise<ServiceBenefitPopupItem[]>Get VAS benefits popup content (vouchers to claim / auto-claimed)
(batchId: string) => Promise<ClaimResultItem[]>Claim VAS benefits
getVasNotifyConfig() => Promise<VasNotifyConfig>Get VAS notification settings (scenario switches and push methods)
(params: ) => Promise<VasNotifyConfig>Update VAS notification settings (incrementally update a single switch by key path)
getVoipAuth() => Promise<VoipAuth>Get VoIP service authorization / push target info
(userId: string) => Promise<boolean>Set the VoIP push target (select the family member to receive incoming calls).
getGestureStatus() => Promise<GestureStatus>Query gesture password status (enabled or not + cloud password string).
(isForce: boolean) => Promise<CurrentUser>Get the current user
getCurrentUserSync() => CurrentUserSynchronously read the current user from cache (no request is made).
() => Read the device's overall status (online/sleep, etc.).
(callback: (status: ) => void) => voidSubscribe to aggregated device status changes (online/sleep, etc.).
(callback: (status: ) => void) => voidUnsubscribe from device status changes (must use the same `callback` reference as when subscribing).
(code: string) => DpValueRead the current value of a device DP
(dpCode: string) => booleanCheck whether the device supports a DP
(dpData: Record<string, DpValue>, option: ) => Promise<Record<string, DpValue>>Send DP to the device
(callback: (dps: ) => void) => voidListen for offline DP updates
(callback: (dps: ) => void) => voidUnregister the offline DP update listener
(dps: Record<string, DpValue>) => Promise<void>Send offline DP
(isForce: boolean) => Promise<>Get offline DP list
(code: string) => OfflineDpInfoGet the offline DP cache entry for the specified code
(code: string) => booleanDetermine whether the specified offline DP is still syncing (push not completed).
(params: ) => Promise<getUsersResult>Query the user list with pagination/keywords.
(params: ) => Promise<>Get details of a single user.
(params: ) => Promise<void>Update user validity, permanent flag, and offline unlock restrictions.
(userId: string) => Promise<void>Open the home user details page
(params: ) => Promise<void>Add a regular user
(userId: string) => Promise<void>Delete a regular user
(params: ) => Promise<AddSharedUserResult>Add a shared user (Bluetooth door lock).
(params: ) => Promise<void>Update a shared user (Bluetooth door lock).
(params: ) => Promise<void>Remove a shared user (Bluetooth door lock).
getSharedUserList() => Promise<SharedUserInfo[]>Get the shared user list
openAddFamilyUser() => Promise<void>
syncDeleteUsers() => Promise<void>Trigger the cloud/device sync process to delete user-related data.
syncUnlockMethod() => Promise<void>Send a command to the device to synchronize unlock methods
(id: number) => Promise<UnlockMethodDetail>Get unlock method details
checkSpecialSupportPhone() => booleanCheck whether SMS notifications are supported
(params: ) => Promise<CreateUnlockMethodResult>Add a password-type unlock method.
(params: ) => Promise<StartAddUnlockMethodResult>Start adding an unlock method
(params: ) => Promise<void>Cancel the ongoing add unlock method process.
(params: ) => Promise<void>Update unlock method
(id: number) => Promise<void>Delete an unlocking method.
checkUnBindUnlockMethods() => Promise<boolean>Check whether there are unbound unlocking methods
getUnbindUnlockMethods() => Promise<UnBindUnlockMethodGroup[]>Get the list of unbound unlocking methods
(params: ) => Promise<boolean>Bind unbound unlocking methods to a user
(id: number) => Promise<void>Unbind the user's unlocking method
(params: ) => Promise<boolean>No unlocking method is associated with the user in the binding record
(params: ) => Promise<void>Send SMS verification code
(listener: (event: AddUnlockMethodEvent) => void) => voidRegister a step listener for unlocking methods
(listener: (event: AddUnlockMethodEvent) => void) => voidUnregister the step listener for unlocking methods
(type: UnlockMethodType) => Promise<UnlockGuide>Get the guide image or video for the specified unlock method type
(params: ) => Promise<TempPasswordResult>Create a custom temporary password.
(params: ) => Promise<boolean>Delete a custom temporary password.
(params: ) => Promise<boolean>Update a custom temporary password.
getTempEffectiveList() => Promise<EffectivePasswrodItem[]>Get the list of active temporary passwords.
(params: ) => Promise<GetTempInvalidListResult>Get the list of invalid temporary passwords
clearTempInvalidList() => Promise<boolean>Clear the list of invalid temporary passwords
(params: ) => Promise<boolean>Freeze the specified custom temporary password.
(params: ) => Promise<boolean>Unfreeze the specified custom temporary password.
(params: ) => Promise<void>Rename the temporary password
(params: ) => Promise<SaveTempOnlineUnlimitedResult>Save an online unlimited-use password
(id: string) => Promise<void>Delete an online unlimited-use password
getTempOnlineUnlimitedList() => Promise<OnlinePasswordItem[]>Get the list of online unlimited-use passwords
(params: ) => Promise<OfflineTempResult>Create an offline temporary password.
(pwdTypeCode: OfflinePasswordType) => Promise<EffectivePasswrodItem[]>Get the list of valid offline passwords
(pwdTypeCode: OfflinePasswordType) => Promise<EffectivePasswrodItem[]>Get the list of expired offline passwords
(params: ) => Promise<TempPasswordResult>Create a time-limited temporary password
(params: ) => Promise<TempPasswordResult>Create a single-use temporary password
createTempDynamic() => Promise<TempPasswordResult>Create a dynamic temporary password.
(params: ) => Promise<TempPasswordResult>Create an offline password clear code
getTempLimitListForClear() => Promise<LimitTempItem[]>Get clearable time-limited password list
checkRemoteEnabled() => Promise<void>Check whether (Wi‑Fi) remote unlocking is currently allowed.
(option: ) => Promise<void>Unlock
(option: ) => Promise<void>Lock
(state: boolean) => Promise<void>Enable or disable the remote lock/unlock feature
getRemoteEnabled() => booleanGet remote lock/unlock enablement status
getRemotePermission() => RemotePermissionTypeGet current remote open/close door permissions
(permission: RemotePermissionType) => Promise<void>Update the remote open/close door permission policy
(option: ) => Promise<void>Approve remote door-open request (used by Wi‑Fi Pro solution)
(option: ) => Promise<void>Reject remote door-open request (Wi‑Fi Pro and similar confirmation flows)
getVoiceUnlockPwdEnabled() => Promise<boolean>Check whether the voice unlock passcode capability is enabled
voiceUnlockPwdDisabled() => Promise<boolean>Disable the voice unlock passcode capability
(password: string) => Promise<boolean>Update the voice unlock passcode
getRemotePermissionList() => RemotePermissionType[]
(cb: () => void) => voidRegister for log-refresh notifications
(cb: () => void) => voidUnregister the log-refresh notification
getLatestLogs() => Promise<GetLatestLogsResult>Get the most recent 2 records
(params: ) => Promise<GetLogsResult>Get log record list
(params: ) => Promise<GetAlarmsResult>Get alarm log list
(params: ) => Promise<GetAlbumsResult>Get album logs
(params: ) => Promise<GetLockLogListResult>Get device log list
Supports operation logs, unlock logs, lock logs, and alarm logs
getAlarmUnreadCount() => Promise<number>Get the number of unread alerts
getActivePeriod() => Promise<number>Get valid security days (since device activation)
unlockDp2TypeRecord<string, UnlockMethodType>
getWiFiSignal() => Promise<void>Get device signal strength
getCurrentWiFiSignal() => number | "unknown"Get Wi-Fi signal strength
(cb: (params: WiFiSignalChangeParams) => void) => voidSubscribe to Wi‑Fi signal changes
(cb: (params: WiFiSignalChangeParams) => void) => voidUnsubscribe from Wi‑Fi signal changes
isSleep() => booleanWhether currently in sleep mode
hasSleepAbility() => booleanCheck whether the lock supports the sleep feature
isEnabledSleep() => booleanCheck whether the sleep feature is enabled
enableSleep() => Promise<void>Enable the sleep feature
disableSleep() => Promise<void>Disable the sleep feature
getSleepPeriod() => GetDpPeriodTimeResultGet the sleep time range
(params: ) => Promise<void>Set the sleep time range
(callback: (args: SleepStatusChangeEvent) => void) => voidRegister sleep-state change event
(callback: (args: SleepStatusChangeEvent) => void) => voidUnregister sleep-state change event
(options: ) => Promise<void>Open the Smart Scene page
isSupportBleControl() => booleanCheck whether Bluetooth control is supported
(dpCode: string) => GetDpPeriodTimeResultGet the current value of a time-range DP
(dpCode: string, data: , option: ) => Promise<void>Update the time range of a time-range DP
(options: ) => Promise<true>Initiate the near-field/LAN device connection flow.
(params: ) => Promise<void>Navigate to host pages such as Value-added Services/Cloud Storage.
(password: string) => Promise<boolean>Validate password complexity per product rules.
(dpValue: string) => ParseDpPeriodTimeResult
(start: number, end: number) => any
(params: ) => Promise<boolean>Set/toggle the gesture password (if a password already exists, you can toggle it directly without the native panel).
(params: ) => Promise<MediaUrlResult>Get the actual playback URL of a video
isSupportMedia() => booleanWhether media capabilities (video/snapshot, etc.) are supported.
getMediaRotate() => MediaRotateGet the device camera rotation angle
getMediaInfo() => MediaInfoGet device camera data
(params: ) => Promise<void>Open local album
(params: ) => Promise<void>Open the playback/cruise monitoring panel
isSupportMultiCamera() => booleanWhether multi-camera switching is supported
getCameraInfo() => CameraDpInfoGet camera info
queryCameraInfo() => Promise<CameraDpInfo>Query camera info
(index: number) => Promise<true>Switch the camera to the specified index
getMediaViewTimes() => Promise<MediaViewTimesResult>Get this month's media view count
addMediaViewTimes() => Promise<MediaViewTimesResult>Set this month's media view count
getAlbumDateList() => Promise<getAlbumDateListResult>Get the list of dates with album records in the last 30 days
getCameraConfig() => CameraConfig[]Get information for all cameras
() => Promise<[]>Get voice file list
(file: ) => Promise<true>Deliver the voice file to the device
(callback: (event: VoiceFileProgressEvent) => void) => voidSubscribe to voice file delivery progress
(callback: (event: VoiceFileProgressEvent) => void) => voidUnsubscribe from voice file delivery progress
getCurrentVoiceFile() => VoiceFileStatusGet current voice file status
getDoorbellService() => Promise<LinkageRule>Get doorbell notification service info
enableDoorbellService() => Promise<void>Enable the doorbell notification service
disableDoorbellService() => Promise<void>Disable the doorbell notification service
toSetDoorbellService() => Promise<void>Go to configure the doorbell notification service
getRemainingInfo() => Promise<RemainingInfo>
(capability: ProductCommunicationType) => booleanWhether a certain `ProductCommunicationType` capability is supported.
isBlePureDevice() => booleanWhether the current device is a pure Bluetooth lock (no Wi‑Fi/Thread or other communication capabilities).
getDeviceAdvancedAbilities() => Promise<DeviceAdvancedAbility>Fetch the device value‑added capability list (cloud).
getDeviceAdvancedAbilitiesSync() => DeviceAdvancedAbilitySynchronously retrieve the list of device value-added capabilities
getDeviceCapabilities() => CapabilityInfoGet device capabilities
getAIReport() => Promise<AIReportPopup>Get the pending AI monthly report; returns null if disabled or none available.
(reportId: string) => Promise<void>Mark the AI monthly report as read (to prevent duplicate pop-ups).
isAIReportEnabled() => Promise<boolean>Whether the AI data report is enabled (cloud capability ai_data_report && device property LOCK_UNLOCK_REPORT).
(fit: ) => Promise<unknown>Bind an accessory to the current door lock.
(fit: & ) => Promise<unknown>Unbind the accessory from the current door lock.
() => Promise<[]>Get the list of accessories currently bound to the lock.
() => Promise<[]>Get the list of accessories that can be bound to the current lock.
(params: ) => Promise<ScreenEventListResult>Get the paginated list of activity events for the current detached screen.
getScreenBoundLockList() => Promise<BoundLockListResult>Get the list of locks currently bound to the detached screen.
getScreenBindableLockList() => Promise<BindableLockListResult>Get the list of locks that can be bound to the current detached screen.
(lockDevId: string) => Promise<AddBindingResult>Initiate binding the specified lock to the current detached screen.
(listener: (event: BindLockToScreenEvent) => void) => voidSubscribe to the result of binding a lock to the detached screen.
(listener: (event: BindLockToScreenEvent) => void) => voidUnsubscribe from the result of binding a lock to the detached screen (must use the same reference as in subscribe).
(relationId: string) => Promise<UnbindingResult>Remove the specified binding relation and return after the unbinding result converges in the cloud.
getBoundLockList() => Promise<BoundLockListItem[]>Get the list of locks bound to the current accessory; each item includes a security version compatibility check
getUnbindLockList() => Promise<UnbindLockListItem[]>Get the list of locks that can be bound to the current accessory; each item includes a bindability check
(lock: ) => Promise<unknown>Bind the lock to the current accessory
(lock: & ) => Promise<unknown>Unbind the lock from the current accessory
(lock: ) => Promise<void>Activate a bound lock device
(params: ) => Promise<void>Add a password on the accessory side
(params: ) => Promise<FitStartAddUnlockMethodResult>Start a multi-stage process on the accessory side to add an unlock method (fingerprint/card/face, etc.)
(params: ) => Promise<void>Cancel the in-progress add-unlock-method process on the accessory side
(listener: (event: FitAddUnlockMethodEvent) => void) => voidRegister an accessory-side listener for add-unlock-method steps
(listener: (event: FitAddUnlockMethodEvent) => void) => voidUnregister the accessory-side listener for add-unlock-method steps
(params: ) => Promise<void>Update an unlock method on the accessory side (cloud-only)
(id: number, lockDevId: string) => Promise<void>Delete an unlock method on the accessory side
(params: ) => Promise<FitUnlockMethodItem[]>Get the list of unlock methods of the specified type for the accessory.
(dpCodes: string[]) => Promise<SyncOpenModeRiseResult>Initiate unlock-method synchronization.
getFitBleKeyList() => Promise<FitBleKeyItem[]>Get the accessory's Bluetooth key list.
(params: Record<string, unknown>) => Promise<unknown>Add a Bluetooth key on the accessory side.
(userId: string) => Promise<unknown>Create a permanent Bluetooth key on the accessory side
(params: ) => Promise<unknown>Create a temporary Bluetooth key on the accessory side
(params: ) => Promise<unknown>Update the temporary Bluetooth key on the accessory side (rename/change the validity period)
(params: ) => Promise<unknown>Delete a Bluetooth key on the accessory side.
(params: ) => Promise<unknown>Rename a Bluetooth key on the accessory side.
getFitUsers() => Promise<FitUserItem[]>Get the member (user) list for the accessory.
(params: ) => Promise<GetLogsResult>Get the accessory's door open/close record list
getFitPasswordList() => Promise<FitPasswordItem[]>Get the current accessory's online password list.
getFitOnlinePasswordList() => Promise<FitOnlinePasswordItem[]>Get the current accessory's online password details list (retaining original fields such as opModeType/effective period/phone number/lock name).
getFitOfflinePasswordList() => Promise<FitOfflinePasswordItem[]>Get the list of valid offline temporary passwords for the current accessory.
(params: ) => Promise<AddFitTempPwdResult>Add a temporary password on the accessory.
(params: ) => Promise<void>Delete a temporary password on the accessory.
(params: ) => Promise<void>Modify a temporary password on the accessory.
(params: ) => Promise<void>Rename a temporary password on the accessory.
(params: ) => Promise<void>Rename an offline temporary password on the accessory (cloud-only).
(params: ) => Promise<FitOfflineClearCodeResult>Delete an offline temporary password on the accessory: generate a 'clear code' (cloud-only).
(params: ) => Promise<boolean>Resend the temporary password SMS.
(params: ) => Promise<FitInvalidPwdListResult>Retrieve the list of expired passwords for the accessory.
(params: ) => Promise<boolean>Clear the accessory's expired passwords.
getFitDynamicPassword() => Promise<TempPasswordResult>Get the current accessory's dynamic password (short-term validity; usable multiple times within 5 minutes).
getFitOfflineOncePassword() => Promise<FitOfflineOnceResult>Get the current accessory's one-time offline password
(params: ) => Promise<FitOfflineOnceResult>Get the current accessory's time-limited offline password
getFitOfflineClearAllCode() => Promise<FitOfflineOnceResult>Generate the 'Clear All' erase code
getFitOfflineRevocableList() => Promise<LimitOfflinePwdItem[]>Get the list of offline passwords that can be "cleared individually" (time-limited offline passwords used at least once).
(pwdType: string) => Promise<OfflinePwdAvailableResult>Check whether a given type of offline password for the current accessory can still be obtained (one-time/clear codes limited to 10 per hour).
typeDpValueUnion of primitive DP payload values
string | boolean | number
enumRemotePermissionType
ValueActual ValueDescription
RemotePermissionType.EVERY_ONEeveryOneEveryone allowed
RemotePermissionType.ADMINS_ONLYadminsOnlyAdmins only
RemotePermissionType.NO_ONEnoOneNo one allowed
enumProductCommunicationType
ValueActual ValueDescription
ProductCommunicationType.WIFI0-
ProductCommunicationType.CABLE1-
ProductCommunicationType.GPRS2-
ProductCommunicationType.NB_IOT3-
ProductCommunicationType.BLUETOOTH10-
ProductCommunicationType.BLE_MESH11-
ProductCommunicationType.ZIGBEE12-
ProductCommunicationType.INFRARED13-
ProductCommunicationType.SUBPIECES14-
ProductCommunicationType.SIGMESH15-
ProductCommunicationType.MCU16-
ProductCommunicationType.TY_SMESH17-
ProductCommunicationType.ZWAVE18-
ProductCommunicationType.PL_MESH19-
ProductCommunicationType.CAT120-
ProductCommunicationType.BEACON21-
ProductCommunicationType.CAT422-
ProductCommunicationType.CAT1023-
ProductCommunicationType.LTE_CATM24-
ProductCommunicationType.THREAD25-
typeWeekWeekly repeat bitmap: indices 0–6 correspond to Sun–Sat; 0 inactive, 1 active
export type Week = [
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
  BitStatus,
];
enumUserType
ValueActual ValueDescription
UserType.ADMIN10Administrator
UserType.MEMBER20Member
UserType.UNKNOW30Anonymous
UserType.SHARE40Shared member
UserType.OWNER50Home owner

Valid Values

SDKOptions.logLevel
ValueDescriptionSince
off--
error--
warn--
info--
debug--
trace--
SDKOptions.kind
ValueDescriptionSince
lock--
fit--
screen--
UpdateConfigParams.logLevel
ValueDescriptionSince
off--
error--
warn--
info--
debug--
trace--
UpdateConfigParams.kind
ValueDescriptionSince
lock--
fit--
screen--
DeviceStatus.type
ValueDescriptionSince
offline--
online--
sleep--
DeviceStatus.onlineTypes
ValueDescriptionSince
local--
cloud--
ble--
localMatter--
yuChannel--
unknown--
Week
ValueDescriptionSince
0--
1--
UserInfo.unlockDetails.type
ValueDescriptionSince
finger--
face--
password--
card--
fingerVein--
hand--
eye--
UserType
ValueDescriptionSince
10Administrator-
20Member-
30Anonymous-
40Shared member-
50Home owner-
EffectiveConfig.repeat
ValueDescriptionSince
none--
week--
AddSharedUserParams.effectiveType
ValueDescriptionSince
once--
permanent--
limit--
UpdateSharedUserParams.effectiveType
ValueDescriptionSince
once--
permanent--
limit--
StartAddUnlockMethodParams.type
ValueDescriptionSince
finger--
face--
password--
card--
fingerVein--
hand--
eye--
CancelAddUnlockMethodParams.type
ValueDescriptionSince
finger--
face--
password--
card--
fingerVein--
hand--
eye--
BindUnlockMethodParams.unlockList.type
ValueDescriptionSince
finger--
face--
password--
card--
fingerVein--
hand--
eye--
BindUnlockMethodFromLogParams.unlockList.type
ValueDescriptionSince
finger--
face--
password--
card--
fingerVein--
hand--
eye--
RemotePermissionType
ValueDescriptionSince
everyOneEveryone allowed-
adminsOnlyAdmins only-
noOneNo one allowed-
GetLockLogListParams.logCategories
ValueDescriptionSince
operation--
unlock_record--
close_record--
alarm_record--
OpenSceneOptions.executorRange
ValueDescriptionSince
unlock--
lock--
OpenSceneOptions.abilities
ValueDescriptionSince
backHome--
alarm--
geographyArrive--
geographyLeave--
bleGeofence--
siriUnlock--
siriLock--
GotoServiceParams.tab
ValueDescriptionSince
cloudStorage--
AI--
voip--
GotoPlaybackParams.tabs
ValueDescriptionSince
local--
cloud--
ProductCommunicationType
ValueDescriptionSince
0--
1--
2--
3--
10--
11--
12--
13--
14--
15--
16--
17--
18--
19--
20--
21--
22--
23--
24--
25--
FitStartAddUnlockMethodParams.type
ValueDescriptionSince
finger--
face--
password--
card--
fingerVein--
hand--
eye--
FitCancelAddUnlockMethodParams.type
ValueDescriptionSince
finger--
face--
password--
card--
fingerVein--
hand--
eye--
GetFitUnlockMethodListParams.type
ValueDescriptionSince
finger--
face--
password--
card--
fingerVein--
hand--
eye--
AddFitTempPwdParams.type
ValueDescriptionSince
once--
limit--

Examples

Create a separate instance per lock device

import { createSDK } from '@ray-js/lock-sdk';
const a = await createSDK({ deviceId: 'devA' });
const b = await createSDK({ deviceId: 'devB' });
await a.openDoor();

Accessory instance

const fit = await createSDK({ deviceId: 'devFit', kind: 'fit' });