Smart Lock Basic API

Last Updated on : 2023-06-28 02:13:44download

Wi-Fi lock basic API

Wi-Fi lock basic API encapsulates common methods regarding temporary passwords, member management, logging capabilities, and more features. These methods apply to camera locks (categoryCode: wf_jtmspro) and smart video locks (categoryCode: videolock_1w_1).

Temporary passwords

Temporary passwords are classified into online passwords and offline passwords.

  • Online temporary password: This type of password is generated when the respective lock runs online and then synced to the lock.

  • Offline temporary password: This type of password is generated even when the respective lock stays offline. Offline passwords are deleted differently from online passwords. Enter a clearing code on the lock, so all offline passwords are cleared from the lock.

The API methods to get online and offline passwords can vary, depending on different lock categories. These capabilities are implemented respectively for camera locks (categoryCode: wf_jtmspro) and smart video locks (categoryCode: videolock_1w_1). For more information, see Demo.

Temporary passwords of camera locks

Access features of a camera lock

IPhotoLock getPhotoLockManager();

Example

val iThingLockManager = ThingOptimusSdk.getManager(IThingLockManager::class.java)
val iVideoLockManager = iThingLockManager?.newVideoLockManagerInstance(mDevId)
val iPhotoLock = iVideoLockManager?.photoLockManager

Create an online temporary password

API description

Creates an online temporary password.

void createOnlineTempPassword(String password, String countryCode, String phone, long effectiveTime,long invalidTime, int availableTimes, String name, List<ScheduleBean> scheduleBean, IThingResultCallback<OnlineTempPassword> callback);

Parameters

Parameter Optional Description
password No It is a 7-digit password by default.
countryCode Yes The country code.
phone Yes The mobile phone number.
effectiveTime No The time when the password takes effect. Unit: milliseconds.
invalidTime No The time when the password expires. Unit: milliseconds.
availableTimes No The number of times the password can be used. Valid values:
  • 0: as many times as needed before the password expires
  • 1: once only
name Yes The name of the password.
scheduleBean No The days on which the password is valid within a week.
scheduleBean.allDay No Specifies whether the password is valid all day long.
scheduleBean.effectiveTime Yes The time when a password becomes valid on that day. Unit: minutes.
scheduleBean.invalidTime Yes The time when a password expires on that day. Unit: minutes. For example, to make the password valid from 10:30 to 12:00, apply these settings: effectiveTime=10\*60+30 and invalidTime = 12\*60. However, this parameter does not apply when allDay=true is used.
scheduleBean.workingDay No The number of valid days within a week. The bit for a valid day is set to 1 and that for an invalid day is set to 0. The bits represent [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday] sequentially from left to right. For example, to make the password valid only on Monday and Tuesday, set this parameter to 1001111, convert the binary value to a decimal value, and then pass in the conversion result.

Example

val scheduleBean = ScheduleBean()
        scheduleBean.allDay = true
        scheduleBean.workingDay = 127
        val list:MutableList<ScheduleBean> = ArrayList()
        list.add(scheduleBean)

        iPhotoLock?.createOnlineTempPassword("1231231",
            "86",
            "",
            System.currentTimeMillis(),
            System.currentTimeMillis() + 7 * 24 * 60 * 60 * 1000,
            0,
            "pwd ",
            list,
            object : IThingResultCallback<OnlineTempPassword> {
                override fun onSuccess(result: OnlineTempPassword?) {
                    ToastUtil.shortToast(mContext, "Create Success")
                    result?.let {
                        pwdList.add(it.pwdId)
                    }

                }

                override fun onError(errorCode: String?, errorMessage: String?) {
                    ToastUtil.shortToast(mContext, errorMessage)
                }

            })

Update the name of an online password

API description

void updateTempPasswordName(String pwdId, String name, IResultCallback callback);

Parameters

Parameter Optional Description
pwdId No The password ID.
name Yes The name of the password.

Example

iPhotoLock?.updateTempPasswordName(
            pwdId,
            "testt",
            object : IResultCallback {
                override fun onError(code: String?, error: String?) {
                    ToastUtil.shortToast(mContext, error)
                }

                override fun onSuccess() {
                    ToastUtil.shortToast(mContext, "Update Success")
                }

            })

Delete an online temporary password

API description

void deleteTempPassword(String pwdId, IResultCallback callback);

Example

iPhotoLock?.deleteTempPassword("pwdId", object : IResultCallback {
            override fun onError(code: String?, error: String?) {
                ToastUtil.shortToast(mContext, error)
            }

            override fun onSuccess() {
                ToastUtil.shortToast(mContext, "Delete Success")
            }
        })

Get a list of online passwords

API description

void getOnlineTempPasswordList(IThingResultCallback<ArrayList<OnlineTempPasswordListBean>> callback);

Parameters of callback for OnlineTempPasswordListBean

Parameter Description
id The password ID, equivalent to pwdId.
phone The mobile phone number.
effective Indicates whether the password is valid. Valid values:
  • 1: to be valid
  • 2: to be sent
  • 3: in use
  • 4: to be deleted
  • 5: expired
effectiveTime The time when the password takes effect. Unit: milliseconds.
invalidTime The time when the password expires. Unit: milliseconds.
availTime The number of times the password can be used. Valid values:
  • 0: as many times as needed before the password expires
  • 1: once only
sn The hardware serial number (SN) of the temporary password.
name The name of the password.
phase The status of the password. Valid values:
  • 1: to be sent
  • 2: sent
  • 0: Deleted
gmtCreate The time when the password was created.
timeZoneId The time zone.
scheduleDetails The days on which the password is valid within a week.

Example

iPhotoLock?.getOnlineTempPasswordList(object :
            IThingResultCallback<ArrayList<OnlineTempPasswordListBean>> {
            override fun onSuccess(result: ArrayList<OnlineTempPasswordListBean>?) {
                ToastUtil.shortToast(mContext, "Get List Success")               
            }

            override fun onError(errorCode: String?, errorMessage: String?) {
                ToastUtil.shortToast(mContext, errorMessage)
            }

        })

Get offline password of camera lock

An offline password is generated only in the cloud and returned to the app.

API description

void getOfflinePassword(long gmtStart, long gmtExpired, OfflineTypeEnum offlineTypeEnum,
                            String countryCode, String pwdName, String mobile, IThingResultCallback<OfflineTempPasswordBean> callback);

Parameters

Parameter Optional Description
gmtStart No The time when the password takes effect.
gmtExpired No The time when the password expires.
offlineTypeEnum No The type of password. Valid values:
  • MULTIPLE: a password that can be used as many times as needed before it expires
  • SINGLE: a one-time password
  • CLEAR_ALL: a clearing code used to delete all offline passwords
countryCode Yes The country code.
pwdName Yes The name of the password.
mobile Yes The mobile phone number.

Example

iPhotoLock?.getOfflinePassword(System.currentTimeMillis()/1000,
            System.currentTimeMillis()/1000 + 24 * 60 * 60 ,
            OfflineTypeEnum.MULTIPLE,
            "",
            "offline pwd",
            "",
            object : IThingResultCallback<OfflineTempPasswordBean> {
                override fun onSuccess(result: OfflineTempPasswordBean?) {
                    ToastUtil.shortToast(mContext, "Get Pwd Success")                  
                }

                override fun onError(errorCode: String?, errorMessage: String?) {
                    ToastUtil.shortToast(mContext, errorMessage)
                }

            })

Name an offline password

API description

void setOfflinePasswordName(String pwdId, String pwdName, String mobile, IResultCallback callback);

Parameters

Parameter Optional Description
pwdId No The password ID.
pwdName Yes The name of the password.
mobile Yes The mobile phone number.

Example

iPhotoLock?.setOfflinePasswordName("pwdId",
            "offline update",
            "",
            object : IResultCallback {
                override fun onError(code: String?, error: String?) {
                    ToastUtil.shortToast(mContext, error)
                }

                override fun onSuccess() {
                    ToastUtil.shortToast(mContext, "Update Pwd Success")
                }

            })

Get clearing code of offline passwords

API description

void getClearCode(String pwdId, IThingResultCallback<OfflineTempPasswordBean> callback);

Example

iPhotoLock?.getClearCode("pwdId",
            object : IThingResultCallback<OfflineTempPasswordBean> {
                override fun onSuccess(result: OfflineTempPasswordBean?) {
                    ToastUtil.shortToast(mContext, " get clear code:${result?.pwd}")
                }

                override fun onError(errorCode: String?, errorMessage: String?) {
                    ToastUtil.shortToast(mContext, errorMessage)
                }

            })

Get a list of offline temporary passwords

API description

void getOfflinePasswordList(OfflineTypeEnum offlineTypeEnum, int offset, int limit, OfflinePasswordStatusEnum offlinePasswordStatusEnum,
                                IThingResultCallback<ArrayList<OfflinePasswordListBean>> callback);

Parameters

Parameter Optional Description
offlineTypeEnum No The type of password. Valid values:
  • MULTIPLE: a password that can be used as many times as needed before it expires
  • SINGLE: a one-time password
  • CLEAR_ALL: a clearing code that is used to delete all offline passwords
offset No The page number.
limit No The maximum number of entries to be returned per page.
offlinePasswordStatusEnum No The status of the password. Valid values:
  • TO_BE_USED: generated and unused
  • USED: in use
  • EXPIRED: expired

Parameters of callback for OfflinePasswordListBean

Parameter Description
opModeSubType The subtype of opModeType.
pwdTypeEnum The type of password. Valid values:
  • MULTIPLE: a password that can be used as many times as needed before it expires
  • SINGLE: a one-time password
  • CLEAR_ALL: a clearing code that is used to delete all offline passwords
hasClearPwd Indicates whether a clearing code is generated.
timeZoneId The time zone.
mobile The mobile phone number.
opModeType The unlocking method. Valid values:
  • 1: unlock with an online temporary password
  • 3: unlock with an offline password that can be used as many times as needed before it expires
  • 8: unlock with a one-time offline password
  • 9: a clearing code that is used to delete all offline passwords
gmtCreate The time when the password was created. Unit: milliseconds.
gmtStart The time when the password takes effect. Unit: milliseconds.
gmtExpired The time when the password expires. Unit: milliseconds.
pwdTypeCode The type of password. Valid values:
  • multiple: a password that can be used as many times as needed before it expires
  • once: a one-time password
  • clear_one: a clearing code used to delete a single password
  • clear_all: a clearing code used to delete all passwords
optUid The user ID (UID).
revokedPwdName The name of the clearing code.
pwdName The name of the password.
pwdId The password ID.
pwd The password.
deliveryStatus Indicates whether the password is confirmed to be sent.
email The email address.
statusEnum The status of the password. Valid values:
  • TO_BE_USED: not used
  • USED: in use
  • EXPIRED: expired

Get offline temporary passwords used unlimited times before expiration

API description

void getNoLimitOfflinePassword(IThingResultCallback<ArrayList<OfflineTempPasswordBean>> callback);

Example

iPhotoLock?.getNoLimitOfflinePassword(object :
            IThingResultCallback<ArrayList<OfflineTempPasswordBean>> {
            override fun onSuccess(result: ArrayList<OfflineTempPasswordBean>?) {
                ToastUtil.shortToast(mContext, "password:${result?.toString()}")
            }

            override fun onError(errorCode: String?, errorMessage: String?) {
                ToastUtil.shortToast(mContext, errorMessage)
            }

        })

Temporary passwords of smart video locks

Get hardware SN of device

API description

Returns the hardware SN in an unlocking method reported by a smart video lock. This hardware SN applies to an unlocking method, such as a temporary password.

void getDeviceSN(String dpId,IThingResultCallback<Integer> callback);

Parameters

Parameter Optional Description
dpId No The value of dpId for an unlocking method, such as an online temporary password.
callback Yes The hardware SN returned.

Example

  iVideoLock?.getDeviceSN( "69", object : IThingResultCallback<Int> {
            override fun onSuccess(result: Int?) {
                
            }

            override fun onError(errorCode: String?, errorMessage: String?) {
                ToastUtil.shortToast(mContext, errorMessage)
            }

        })

Create an online temporary password

API description

void createOnlineTempPassword(int sn, String password, long effectiveTime, long invalidTime,
                                  int availableTimes, String name, List<ScheduleBean> scheduleBean, IThingResultCallback<String> callback);

Parameters

Parameter Optional Description
sn No The hardware SN of the temporary password.
password No The password that is 4 to 15 characters in length.
effectiveTime No The time when the password takes effect. Unit: milliseconds or seconds.
invalidTime No The time when the password expires. Unit: milliseconds or seconds.
availableTimes No The number of times the password can be used. Valid values:
  • 0: as many times as needed before it expires
  • 1: once only
name Yes The name of the password.
scheduleBean No The days on which the password is valid within a week.
scheduleBean.allDay No Specifies whether the password is valid all day long.
scheduleBean.effectiveTime Yes The time when a password becomes valid on that day. Unit: minutes.
scheduleBean.invalidTime Yes The time when a password expires on that day. Unit: minutes. For example, to make the password valid from 10:30 to 12:00, apply these settings: effectiveTime=10\*60+30 and invalidTime = 12\*60. However, this parameter does not apply when allDay=true is used.
scheduleBean.workingDay No The number of valid days within a week. The bit for a valid day is set to 1 and that for an invalid day is set to 0. The bits represent [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday] sequentially from left to right. For example, to make the password valid only on Monday and Tuesday, set this parameter to 1001111, convert the binary value to a decimal value, and then pass in the conversion result.

Return data

Parameter Description
unlockBindingId The ID of the temporary password.

Example

val scheduleBean = ScheduleBean()
        scheduleBean.allDay = true
        scheduleBean.workingDay = 127
        val list: MutableList<ScheduleBean> = ArrayList()
        list.add(scheduleBean)
        iVideoLock?.createOnlineTempPassword(sn,
            "123124",
            System.currentTimeMillis() / 1000,
            System.currentTimeMillis() + 24 * 60 * 60,
            0,
            "online pwd ",
            list,
            object : IThingResultCallback<String> {
                override fun onSuccess(result: String?) {
                    ToastUtil.shortToast(mContext, "pwd :${result}")                    
                }

                override fun onError(errorCode: String?, errorMessage: String?) {
                    ToastUtil.shortToast(mContext, errorMessage)
                }

            })

Update an online password

API description

Updates an online password, and modifies the date when the password takes effect, as well as its name and validity period.

void updateOnlineTempPassword(String unlockBindingId, String password, long effectiveTime,
                                  long invalidTime, String name, int phase,
                                  List<ScheduleBean>  scheduleBean, IResultCallback callback);

Parameters

Parameter Optional Description
unlockBindingId No The ID of the temporary password.
password No The password.
effectiveTime No The time when the password takes effect. Unit: milliseconds or seconds.
invalidTime No The time when the password expires. Unit: milliseconds or seconds.
name Yes The name of the password.
phase No The status of the password. Valid values:
  • 2: normal
  • 4: frozen
scheduleBean No The days on which the password is valid within a week.
scheduleBean.allDay No Specifies whether the password is valid all day long.
scheduleBean.effectiveTime Yes The time when a password becomes valid on that day. Unit: minutes.
scheduleBean.invalidTime Yes The time when a password expires on that day. Unit: minutes. For example, to make the password valid from 10:30 to 12:00, apply these settings: effectiveTime=10\*60+30 and invalidTime = 12\*60. However, this parameter does not apply when allDay=true is used.
scheduleBean.workingDay No The number of valid days within a week. The bit for a valid day is set to 1 and that for an invalid day is set to 0. The bits represent [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday] sequentially from left to right. For example, to make the password valid only on Monday and Tuesday, set this parameter to 1001111, convert the binary value to a decimal value, and then pass in the conversion result.

Example

val scheduleBean = ScheduleBean()
        scheduleBean.allDay = true
        scheduleBean.workingDay = 127
        val list: MutableList<ScheduleBean> = ArrayList()
        list.add(scheduleBean)        iVideoLock?.updateOnlineTempPassword("unlockBindingId","2223334",System.currentTimeMillis()/1000,
        System.currentTimeMillis()/1000+24*60*60,"online pwd update${num}",2,list,object :IResultCallback{
                override fun onError(code: String?, error: String?) {
                    ToastUtil.shortToast(mContext, error)
                }

                override fun onSuccess() {
                    ToastUtil.shortToast(mContext, "update success ")
                }

            })

Update the name of an online password

API description

void updateOnlineTempPasswordName(String unlockBindingId, String name, IResultCallback callback);

Parameters

Parameter Optional Description
unlockBindingId No The ID of the temporary password.
name Yes The name of the password.

Example

iVideoLock?.updateOnlineTempPasswordName(
            "unlockBindingId",
            "online update",
            object : IResultCallback {
                override fun onError(code: String?, error: String?) {
                    ToastUtil.shortToast(mContext, error)
                }

                override fun onSuccess() {
                    ToastUtil.shortToast(mContext, "update success ")
                }

            })

Delete an online temporary password

API description

void deleteOnlineTempPassword(String unlockBindingId, IResultCallback callback);

Example

iVideoLock?.deleteOnlineTempPassword("unlockBindingId", object : IResultCallback {
            override fun onError(code: String?, error: String?) {
                ToastUtil.shortToast(mContext, error)
            }

            override fun onSuccess() {
                ToastUtil.shortToast(mContext, "success ")
            }
        })

Get an offline temporary password

API description

void getOfflineTempPassword(long gmtStart, long gmtExpired, OfflineTypeEnum offlineTypeEnum,
                                String countryCode, String pwdName, String mobile, IThingResultCallback<OfflineTempPasswordBean> callback);

Parameters

Parameter Optional Description
gmtStart No The time when the password takes effect. Unit: seconds.
gmtExpired No The time when the password expires. Unit: seconds.
offlineTypeEnum No The type of password. Valid values:
  • MULTIPLE: a password that can be used as many times as needed before it expires
  • SINGLE: a one-time password
  • CLEAR_ALL: a clearing code that is used to delete all offline passwords
countryCode Yes The country code.
pwdName Yes The name of the password.
mobile Yes The mobile phone number.

Example

iVideoLock?.getOfflineTempPassword(System.currentTimeMillis() / 1000,
            System.currentTimeMillis() / 1000 + 48 * 60 * 60,
            OfflineTypeEnum.MULTIPLE,
            "86",
            "offline pwd test",
            "",
            object : IThingResultCallback<OfflineTempPasswordBean> {
                override fun onSuccess(result: OfflineTempPasswordBean?) {
                    ToastUtil.shortToast(mContext, result?.toString())
                    result?.let {
                        offlinePwdList.add(it.unlockBindingId)
                    }
                }

                override fun onError(errorCode: String?, errorMessage: String?) {
                    ToastUtil.shortToast(mContext, errorMessage)
                }

            })

Name an offline temporary password

API description

void setOfflineTempPasswordName(String pwdName, String unlockBindingId, IResultCallback callback);

Parameters

Parameter Optional Description
unlockBindingId No The ID of the temporary password.
pwdName Yes The name of the password.

Example

iVideoLock?.setOfflineTempPasswordName(            
            "Offline pwd tt ",
  					"unlockBindingId",
            object : IResultCallback {
                override fun onError(code: String?, error: String?) {
                    ToastUtil.shortToast(mContext, error)
                }

                override fun onSuccess() {
                    ToastUtil.shortToast(mContext, "update success")
                }

            })

Get clearing code of offline passwords

API description

void getClearCode(String pwdName, String unlockBindingId, IThingResultCallback<OfflineTempPasswordBean> callback);

Parameters

Parameter Optional Description
unlockBindingId No The ID of the temporary password.
pwdName Yes The name of the password.

Example

iVideoLock?.getClearCode(
            "clear code",
           "unlockBindingId",
            object : IThingResultCallback<OfflineTempPasswordBean> {
                override fun onSuccess(result: OfflineTempPasswordBean?) {
                    ToastUtil.shortToast(mContext, result?.toString())
                }

                override fun onError(errorCode: String?, errorMessage: String?) {
                    ToastUtil.shortToast(mContext, errorMessage)
                }

            })

Get a list of temporary passwords

API description

Returns a list of online and offline passwords.

void getTempPasswordList(IThingResultCallback<ArrayList<VideoLockTempPasswordBean>> callback);

Parameters of ClearCodeInfo in callback for VideoLockTempPasswordBean

Parameter Description
unlockBindingId The ID of the temporary password.
effectiveTime The time when the password takes effect.
invalidTime The time when the password expires.
name The name of the password.
phase The status of the password. Valid values:
  • 1: normal
  • 2: updating
  • 3: frozen
  • 4: being frozen
  • 9: to be deleted
  • 10: being added
effective The validity status. Valid values:
  • 1: to be valid
  • 2: taking effect
  • 4: expired
opModeType The unlocking method. Valid values:
  • 1: unlock with an online temporary password
  • 3: unlock with an offline password that can be used as many times as needed before it expires
  • 8: unlock with a one-time offline password
opModeSubType The subtype of opModeType.
sn The hardware SN reported by the device.
opModeInfo The information about the clearing code.
hasClearPwd Indicates whether a clearing code is set.
revokedPwdName The name of the clearing code.
revokedPwdEffectiveTime The validity period of the clearing code.
revokedPwdInvalidTime The time when the clearing code expires.

Example

iVideoLock?.getTempPasswordList(object :
            IThingResultCallback<ArrayList<VideoLockTempPasswordBean>> {
            override fun onSuccess(result: ArrayList<VideoLockTempPasswordBean>?) {
                ToastUtil.shortToast(mContext, result?.toString())

            }

            override fun onError(errorCode: String?, errorMessage: String?) {
                ToastUtil.shortToast(mContext, errorMessage)
            }

        })

Member management

Lock members are classified into home members and non-home members.

  • Home member: the same as that defined in the Smart Life App SDK. The Smart Lock SDK can be used to bind a lock password ID with a home member account. For more information, see Home Management.

  • Non-home members: an individual member of a smart lock, only bound with the device. This member can be created and assigned. The Smart Lock SDK can be used to bind a lock password ID with this member.

This section describes the operations regarding non-home members.

Access features of member management

ILockBaseAbilityManager getBaseAbilityManager();

Example

val iThingLockManager = ThingOptimusSdk.getManager(IThingLockManager::class.java)
val iVideoLockManager = iThingLockManager?.newVideoLockManagerInstance(mDevId)
val iLockBaseAbilityManager = iVideoLockManager?.baseAbilityManager

Add a lock member

API description

Adds a lock panel member. Different from a home member, a lock member does not need to be registered and not have permissions to manage other devices that are bound with the current account. A lock member is created to bind an unlocking method with a log entry.

void addUser(String name, File avatar, String sex, Long birthday, Integer height,
                 Integer weight, String heightUnit, IThingResultCallback<String> callback);

Parameters

Parameter Optional Description
name No The username of a member.
avatar Yes The file of a user avatar.
sex Yes The gender of the member.
birthday Yes The birthday of the member.
height Yes The height of the member.
weight Yes The weight of the member.
heightUnit Yes The unit of the height. Valid values:
  • CM: cm
  • INCH: inch
Callback Yes The callback.

Example

iLockBaseAbilityManager?.addUser("User",null,"0",System.currentTimeMillis(),
        180,80,"CM",object :IThingResultCallback<String>{
                override fun onSuccess(result: String?) {                    
                    ToastUtil.shortToast(mContext,"Add Success")
                }

                override fun onError(errorCode: String?, errorMessage: String?) {
                    ToastUtil.shortToast(mContext,errorMessage)
                }

            })

Update member information

API description

Updates the name and avatar of a member.

void updateUser(String userId, String userName, File avatar, IResultCallback callback);

Parameters

Parameter Optional Description
userId No The user ID.
userName Yes The username of a member.
avatar Yes The file of a user avatar.
Callback Yes The callback.

Example

iLockBaseAbilityManager?.updateUser("userId","User",null,
        object :IResultCallback{
            override fun onError(code: String?, error: String?) {
                ToastUtil.shortToast(mContext,error)
            }

            override fun onSuccess() {
                ToastUtil.shortToast(mContext,"Modify Success")
            }

        })

Delete a member

API description

void deleteUser(String userId, IResultCallback callback);

Example

iLockBaseAbilityManager?.deleteUser("userid",object :IResultCallback{
            override fun onError(code: String?, error: String?) {
                ToastUtil.shortToast(mContext,error)
            }

            override fun onSuccess() {
                ToastUtil.shortToast(mContext,"Delete Success")
                
            }

        })

Get a list of members

API description

void getUsersList(IThingResultCallback<ArrayList<WifiLockUserBean>> callback);

Parameters of callback for WifiLockUserBean

Parameter Description
userId The member ID.
avatarUrl The avatar of the member.
userContact The contact information of the member.
nickName The nickname of the member.
userType The user type of the member. Valid values:
  • 10: administrator
  • 20: common home member
  • 40: member who receives a sharing invitation
  • 50: home owner
lockUserId The user ID on the lock.
unlockCountMap The array of the unlocking method quantities. Each key is set to a value of dpId.
unlockList The list of unlocking method names.

Example

iLockBaseAbilityManager?.getUsersList(object :IThingResultCallback<ArrayList<WifiLockUserBean>>{
            override fun onSuccess(result: ArrayList<WifiLockUserBean>?) {
               
            }

            override fun onError(errorCode: String?, errorMessage: String?) {
               
            }

        })

Get member details

API description

Returns details of a member.

void getUserDetail(String userId, IThingResultCallback<WifiLockUserDetail> callback);

Parameters of callback for WifiLockUserDetail

Parameter Description
userId The member ID.
avatarUrl The avatar of the member.
userContact The contact information of the member.
nickName The nickname of the member.
userType The user type of the member. Valid values:
  • 10: administrator
  • 20: common home member
  • 40: member who receives a sharing invitation
  • 50: home owner
unlockDetail The list of unlocking methods.
unlockDetail.dpId The value of dpId for an unlocking method.
unlockDetail.unlockList The details of an unlocking method.
unlockList.opModeId The ID of an unlocking method in the cloud.
unlockList.unlockId The ID of an unlocking method.
unlockList.admin Indicates whether an unlocking method is used by an administrator.
unlockList.unlockName The name of an unlocking method.
unlockList.unlockAttr The attribute of an unlocking method. 1: indicates a duress alarm.
unlockList.photoUnlock Indicates whether capture when unlocking is enabled.
unlockList.allocateFlag Indicates whether a locking method can be unbound from a member. Valid values:
  • 1: yes
  • 0: no

Example

iLockBaseAbilityManager?.getUserDetail(userId,object :IThingResultCallback<WifiLockUserDetail>{
            override fun onSuccess(result: WifiLockUserDetail?) {
                
            }

            override fun onError(errorCode: String?, errorMessage: String?) {
               
            }

        })

Get the number of members

API description

Returns the number of home members and non-home members.

void getUserCount(IThingResultCallback<Pair<Integer, Integer>> callback);

Parameters

Parameter Description
Pair.first The number of home members.
Pair.second The number of non-home members.

Log management

Access features of log management

ILockBaseAbilityManager getBaseAbilityManager();

Example

val iThingLockManager = ThingOptimusSdk.getManager(IThingLockManager::class.java)
val iVideoLockManager = iThingLockManager?.newVideoLockManagerInstance(mDevId)
val iLockBaseAbilityManager = iVideoLockManager?.baseAbilityManager

Get a record most recently generated

API description

void getLatestLog(int userType, String userId, IThingResultCallback<LatestLogBean> callback);

Parameters

Parameter Optional Description
userType No The type of member. Valid values:
  • 0: home member
  • 1: lock panel member
userId No The user ID.
  • For a home member, userId is equivalent to memberId.
  • For a lock panel member, the value is the ID returned when the member is added.
Callback Yes The callback.

Parameters of callback for LatestLogBean

Parameter Description
logCategory The log category. Valid values:
  • operation: operation log
  • unlock_record: unlocking log
  • close_record: locking log
  • alarm_record: alarm log
logType The type of log.
recordType The type of unlocking log entry without a respective locking log entry. Valid values:
  • 1: common unlocking log entry
  • 2: alarm log entry
unlockNameRosettaKey The multilingual setting of a locking log entry.
currentUser Indicates whether the recorded action is taken by the current user.
userId The user ID.
userName The username.
unlockName The name of the unlocking method.
time The time when an event occurs.
relateDevName The name of the associated device.
relateOpMode The details of the associated unlocking method.
unReadCount The number of unchecked log entries.
data The details of an alarm or operation log entry.
channelId The channel ID dedicated for an access control device.
unionUnlockInfo The information about a combination unlocking method.
unionUnlockInfo.currentUser Indicates whether the combination unlocking method is used by the current user.
unionUnlockInfo.sn The hardware SN of the device that is bound with the combination unlocking method.

Example

iLockBaseAbilityManager?.getLatestLog(
                0,
                "userId",
                object : IThingResultCallback<LatestLogBean> {
                    override fun onSuccess(result: LatestLogBean?) {
                       
                    }

                    override fun onError(errorCode: String?, errorMessage: String?) {
                        
                    }

                })

Get log entries

API description

Returns a list of log entries.

void getLogList(String logCategories, String userIds, boolean onlyShowMediaRecord, Long startTime, Long endTime,
                    String lastRowKey, int limit, int userType, String userId, IThingResultCallback<LogsListBean> callback);

Parameters

Parameter Optional Description
logCategories Yes The log category. Valid values:
  • operation: operation log
  • unlock_record: unlocking log
  • close_record: locking log
  • alarm_record: alarm log
userIds Yes The list of user IDs to be returned, separated with commas (,). Example: 12,13.
onlyShowMediaRecord No Indicates whether only log entries with images or video files are returned. Default value: false, used to return all log entries.
startTime Yes The start time of the period to be queried. Unit: milliseconds.
endTime Yes The end time of the period to be queried. Unit: milliseconds.
lastRowKey Yes The row key of the last entry on each page.
limit No The maximum number of entries to be returned per page.
userType Yes The type of member. Valid values:
  • 0: home member
  • 1: lock panel member
userId Yes The user ID.
  • For a home member, userId is equivalent to memberId.
  • For a lock panel member, the value is the ID returned when the member is added.
Callback Yes The callback.

Parameters of MediaInfo in callback for LogsListBean and LogsInfoBean

Parameter Description
hasMore Indicates whether additional data is available.
lastRowKey The row key of the last entry on each page.
records The information about the log entries.
records.logType The type of log.
records.data The data of a data point (DP).
records.recordType The type of unlocking log entry without a respective locking log entry. Valid values:
  • 1: common unlocking log entry
  • 2: alarm log entry
records.dpId The ID of a DP.
records.unlockName The name of an unlocking method. The value can be empty.
records.userName The username.
records.userId The user ID.
records.currentUser Indicates whether the recorded action was taken by the current user.
records.memberBindableFlag Indicates whether an unlocking method can be bound with a member.
records.logId The log ID.
records.time The time when an event occurred.
records.logCategory The log category. Valid values:
  • operation: operation log
  • unlock_record: unlocking log
  • close_record: locking log
  • alarm_record: alarm log
records.mediaInfoList The information about video files and images. This parameter applies to smart video locks, Wi-Fi low-power locks, and keepalive locks when these locks can generate video files and images.
mediaInfoList.fileUrl The URL of a cover image.
mediaInfoList.fileKey The secret key that is used to decrypt a cover image.
mediaInfoList.mediaPath The relative address of a video file.
mediaInfoList.mediaBucket The bucket where a video file is located.
mediaInfoList.mediaKey The secret key that is used to decrypt a video file.

Example

iLockBaseAbilityManager?.getLogList("",
                null,
                false,
                null,
                System.currentTimeMillis(),
                "",
                20,
                0,
                "userid",
                object : IThingResultCallback<LogsListBean> {
                    override fun onSuccess(result: LogsListBean?) {
                        
                    }

                    override fun onError(errorCode: String?, errorMessage: String?) {
                        
                    }

                })

Bind unlocking log with user

API description

By default, the API methods respecting API management are bound with users. This API method can be called to bind recorded unlocking methods with a user.

void bindUnlockWaysToUser(String userId, String[] unlockIds, IResultCallback callback);

Parameters

Parameter Optional Description
unlockIds No The list of unlocking methods. Each element in the list consists of the type of locking method and the unlocking method ID, concatenated with a hyphen (-) in between. Example: [12-01,13-02].
userId No The user ID.
  • For a home member, userId is equivalent to memberId.
  • For a lock panel member, the value is the ID returned when the member is added.
Callback Yes The callback.

Example

val array = arrayOf("${logsInfoBean.dpId}-${logsInfoBean.data}")
            iLockBaseAbilityManager?.bindUnlockWaysToUser("the userid will be bound",
                array, object : IResultCallback {
                    override fun onError(code: String?, error: String?) {
                       
                    }

                    override fun onSuccess() {
                        
                    }

                })

Others

Get rotation angle of a device

API description

void getDevicePhotoRotateAngel(IThingResultCallback<JSONObject> callback);

Example

val iThingLockManager = ThingOptimusSdk.getManager(IThingLockManager::class.java)
        iThingVideoLockManager = iThingLockManager.newVideoLockManagerInstance(mDevId)
        iThingVideoLockManager?.getDevicePhotoRotateAngel(object :IThingResultCallback<JSONObject>{
            override fun onSuccess(result: JSONObject?) {
                TODO("Not yet implemented")
            }

            override fun onError(errorCode: String?, errorMessage: String?) {
                TODO("Not yet implemented")
            }

        })

Get a list of albums

API description

void getAlbumList(IThingResultCallback<AlbumBean> callback);

Parameters of AlbumInfo in callback for AlbumBean

Parameter Description
eventTypes The types of cover images and video files returned in an album.
albumList The list of albums.
albumList.eventType The type of file. For more information, see Definitions of camera lock events.
albumList.fileUrl The URL of a cover image.
albumList.fileKey The secret key that is used to decrypt a cover image.
albumList.mediaPath The URL of a video file.
albumList.mediaKey The secret key that is used to decrypt a video file.
albumList.mediaBucket The bucket where a video file is located.
albumList.uploadTime The time when a file was uploaded.

Destroy an API method

Destroys an API method if respective features are no longer required. This helps to avoid possible errors. This API method applies to the classes IVideoLock, IPhotoLock, and ILockBaseAbilityManager. This API method is called in the following example:

void onDestroy();

Appendix

Definitions of camera lock events

Event status Description Status value
Status 1 Anti-pry alert 0x0000
Status 2 Remote unlocking request 0x0001
Status 3 Fingerprint attempt failed 0x0002
Status 4 Password attempt failed 0x0003
Status 5 Card attempt failed 0x0004
Status 6 Face recognition failed 0x0005
Status 7 Palm print recognition failed 0x0006
Status 8 Finger vein recognition failed 0x0007
Status 9 Unlock with fingerprint 0x0008
Status 10 Unlock with password 0x0009
Status 11 Unlock with card 0x000A
Status 12 Unlock with face recognition 0x000B
Status 13 Unlock with palm vein 0x000C
Status 14 Unlock with finger vein 0x000D
Status 15 Unlock with temporary password 0x000E
Status 16 Unlock with dynamic password 0x000F
Status 17 Remote unlocking 0x0010
Status 18 Report offline password unlocking 0x0011
Status 19 Report doorbell request 0x0012
Status 20 Duress alarm 0x0013
Status 21 Low battery alert 0x0014
Status 22 Mechanical key attempt 0x0015
Status 23 High temperature alert 0x0016
Status 24 Doorbell ringing and remote unlocking 0x0017
Status 25 Loitering alert 0x0018
Status 26 Lock tampering 0x0019
Status 27 Unlock with special fingerprint 0x001A
Status 28 Unlocking in arm mode 0x001B
Status 29 Unlock with remote control 0x001C