Last Updated on : 2024-11-22 02:19:31download
This topic describes how to manage a lock.
API description
ILockSite # void getLockDeviceList(long startId, IThingResultCallback<ArrayList<DeviceBeanWrapper>> callback);
Parameters
Parameter | Description |
---|---|
start_id | The pagination cursor. Pass 0 for the first request. On subsequent requests, its value is the gatewayIndexId of the last device returned in the previous response. |
callback | The callback for getting the lock list. |
Example
ThingOSLock.newSiteInstance(siteId).getLockDeviceList(0L, new IThingResultCallback<ArrayList<DeviceBeanWrapper>>() {
@Override
public void onSuccess(ArrayList<DeviceBeanWrapper> result) {
//Got the lock device list successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to get the lock device list
}
});
20
items per page.start_id
represents the pagination cursor. Pass 0
for the first request. On subsequent requests, its value is the gatewayIndexId
of the last device returned in the previous response.API description
ILockDevice # void getLockDetail(IThingResultCallback<LockDetailBean> callback);
Parameters
Parameter | Description |
---|---|
callback | The callback. |
Example
ThingOSLock.newLockInstance(siteId, deviceId).getLockDetail (new IThingResultCallback<LockDetailBean>() {
@Override
public void onSuccess(LockDetailBean result) {
//Got lock details successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to get lock details
}
});
Fields in LockDeviceBean
Field | Description |
---|---|
deviceId | The device ID of the lock. |
deviceName | The device name of the lock. |
gatewayId | The device ID of the gateway connected to the lock. The value is null if there is no gateway. |
gatewayName | The device name of the gateway connected to the lock. The value is null if there is no gateway. |
deviceType | The type of the lock.
|
online | The connection status of the lock on the internet.
|
electricQuantity | The lock’s battery level. |
deviceRole | The role of the current user.
|
supportAbilities | The capabilities supported by the lock, including:
|
livecycleType | Password validity
|
timeScheduleInfo | The device time setting. |
eKeyId | The ID of the e-key. |
automaticLock | Whether the device supports auto-locking. |
closedOpenedState | The current open/closed status. |
manualCloseFlag | Whether the device supports manual locking in the current status.
|
reverseLockState | The double locking status.
|
connectionStatus | The current connection status. |
isSupportOta | Whether OTA updates are supported. |
timeZoneId | The time zone of the device. |
account | The account associated with the device. |
API description
ILockDevice # void unlock(IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
callback | The unlocking callback. |
Example
ThingOSLock.newLockInstance(siteId, deviceId).unlock( new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Unlocked successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to unlock
}
});
API description
ILockDevice # void lock(IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
callback | The locking callback. |
Example
ThingOSLock.newLockInstance(siteId, deviceId).lock( new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Locked successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to lock
}
});
lock
method, it is recommended to verify if manual locking is supported by checking the manualCloseFlag
in LockDetailBean
.
true
: Manual locking is supported.false
: Manual locking is not supported.API description
ILockDevice # void updateName(String name, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
name | The name of the lock. |
callback | The callback for renaming the lock. |
Example
ThingOSLock.newLockInstance(siteId, deviceId).updateName(newLockName, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Updated name successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to update name
}
});
API description
ILockSite # void deleteLock(String devId, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
devId | The ID of the target lock. |
callback | The callback for deleting the lock. |
Example
ThingOSLock.newSiteInstance(siteId).deleteLock(devId, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Deleted lock successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to delete lock
}
});
To remove a lock using this method, the lock must be online. Otherwise, it cannot be deleted.
API description
ILockSite # void forceDeleteLock(String devId, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
devId | The ID of the target lock. |
callback | The callback for forcibly deleting the lock. |
Example
ThingOSLock.newSiteInstance(siteId).forceDeleteLock(devId, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Deleted lock successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to delete lock
}
});
API description
ILockDevice # void setAutoLockSwitch(boolean autoLockEnable, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
autoLockEnable | Whether the device enables auto-locking. |
callback | The callback for enabling auto-locking. |
Example
ThingOSLock.newLockInstance(siteId, deviceId).setAutoLockSwitch(true, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Enabled auto-lock successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to enable auto-lock
}
});
API description
ILockDevice # boolean isSupportAutoLock();
Parameters
Parameter | Description |
---|---|
Return value | Whether the device supports auto-locking.
|
Example
ThingOSLock.newLockInstance(siteId, deviceId).isSupportAutoLock()
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback