Smart Access Control

Last Updated on : 2022-02-17 06:56:21download

Smart access control is a smart unlocking method to open a door by using an app. Access control can be implemented with multiple methods, such as remote unlocking and QR code. The system dynamically calculates the access control records to facilitate access control for residents and improve the efficiency of property management. Smart access control simplifies door opening and enhances community security.

Feature overview

  • ITuyaCommunitySmartDoor provides the capabilities to unlock a door by tapping on an app or by scanning a QR code.
  • TuyaCommunitySDK.getSmartDoorInstance() is the class to query data.

Query a list of access control devices

Returns a list of smart access control devices assigned to a house.

API description

void getSmartDoorList(String communityId, String roomId, ITuyaCommunityResultCallback<ArrayList<TuyaCommunitySmartDoorInfoBean>> callback);

Request parameter

Parameter Description
communityId The community ID. TuyaCommunitySDK.newHouseInstance(houseId) can be used to get the value of communityId for the current house.
roomId The room ID. TuyaCommunitySDK.newHouseInstance(houseId) can be used to get the value of roomId.
callback The callback.

Parameters of TuyaCommunitySmartDoorInfoBean

Parameter Description
deviceId The device ID. Each device is assigned a unique identifier.
deviceName The name of the device.

Example

TuyaCommunitySDK.getSmartDoorInstance().getSmartDoorList(communityId, roomId, new ITuyaCommunityResultCallback<ArrayList<TuyaCommunitySmartDoorInfoBean>>() {
			@Override
			public void onSuccess(ArrayList<TuyaCommunitySmartDoorInfoBean> tuyaCommunitySmartDoorInfoBeans) {
				// do something
			}

			@Override
			public void onFailure(String s, String s1) {
				// do something
			}
		});

Unlock a door

API description

void openDoor(String communityId, String roomId, String deviceId, ITuyaCommunityResultCallback<String> callback);

Request parameter

Parameter Description
communityId The community ID.
roomId The room ID.
deviceId The device ID. You can call the API method getSmartDoorList to return TuyaCommunitySmartDoorInfoBean and get the value of deviceId.
callback The callback. The ID of the pass record is returned.

Example

TuyaCommunitySDK.getSmartDoorInstance().openDoor(getBlockId(), getRoomId(), bean.getDeviceId(), new ITuyaCommunityResultCallback<String>() {
			@Override
			public void onSuccess(String accessLogId) {
				// do something
			}

			@Override
			public void onFailure(String s, String s1) {
				// do something
			}
		});

Query the unlocking result

Indicates the result of an unlocking operation. This API method can be polled at an interval, such as 0.5 seconds, after the API method openDoor() is called.

API description

	void checkOpenDoorResult(String communityId, String accessLogId, ITuyaCommunityResultCallback<TuyaCommunitySmartDoorOpenResult> callback);

Request parameter

Parameter Description
communityId The community ID.
accessLogId The ID of the pass record.
callback The callback of TuyaCommunitySmartDoorOpenResult. Valid values:
  • 0: unknown
  • 1: successful
  • 2: failed

Example

TuyaCommunitySDK.getSmartDoorInstance().checkOpenDoorResult(getBlockId(), accessLogId, new ITuyaCommunityResultCallback<TuyaCommunitySmartDoorOpenResult>() {
			@Override
			public void onSuccess(TuyaCommunitySmartDoorOpenResult tuyaCommunitySmartDoorOpenResult) {
				// do something
			}

			@Override
			public void onFailure(String s, String s1) {
				// do something
			}
		});

Query unlocking records

API description

void getSmartDoorOpenRecords(String communityId, String roomId, ITuyaCommunityResultCallback<ArrayList<TuyaCommunitySmartDoorOpenRecordBean>> callback);

Request parameter

Parameter Description
communityId The community ID.
roomId The room ID.
callback The callback.

Parameters of TuyaCommunitySmartDoorOpenRecordBean

Parameter Description
accessLogId The ID of a record.
accessControlName The name of the access control device.
accessControlAddress The address of the access control device.
accessTime The time when the record is generated.
accessDirection The device status indicated by a record. Valid values:
  • TuyaCommunitySmartDoorOpenDirection.OUT: 2: get out of the door</li><li>TuyaCommunitySmartDoorOpenDirection.IN: 1: get into the door</li><li>TuyaCommunitySmartDoorOpenDirection.FAILURE: 0`: failed to open the door

Example

TuyaCommunitySDK.getSmartDoorInstance().getSmartDoorOpenRecords(blockId, roomId, new ITuyaCommunityResultCallback<ArrayList<TuyaCommunitySmartDoorOpenRecordBean>>() {
			@Override
			public void onSuccess(ArrayList<TuyaCommunitySmartDoorOpenRecordBean> tuyaCommunitySmartDoorOpenRecordBeans) {
		// do something
			}

			@Override
			public void onFailure(String s, String s1) {
				// do something
			}
		});

Query access control QR code information

Returns an access control QR code to open a door and returns a list of available access control devices and authorized elevator control devices.

API description

void getCommunityQrCode(String communityId, String roomId, ITuyaCommunityResultCallback<TuyaCommunityQRCodeBean> callback);

Parameters of TuyaCommunityQRCodeBean

Parameter Description
qrCodeUrl The URL of a QR code.
expire The time when the QR code expires.
accessDoorList The list of available access control devices. Each element is a device name.
accessElevatorList The list of available elevator control devices. Each element is a device name.

Request parameter

Parameter Description
communityId The community ID.
roomId The room ID.
callback The callback. The QR code URL twoDimensionalCode is returned. The BarcodeFormat.QR_CODE mode of ZXing can be used to convert the QR code into a Bitmap. For more information, see the implementation of the sample code for the Smart Community App SDK.

Example

TuyaCommunitySDK.getSmartDoorInstance().getCommunityQrCode(communityId, roomId, new ITuyaCommunityResultCallback<TuyaCommunityQRCodeBean>() {
			@Override
			public void onSuccess(TuyaCommunityQRCodeBean bean) {
				// do something
			}

			@Override
			public void onFailure(String s, String s1) {
				// do something
			}
		});