1. Shared Devices

When a device needs to be provided for other users to operate, the device can be shared with other users, and the user who receives the shared device can simply operate the device.

Class Name Description
ITuyaHomeDeviceShare Share device, get share info, manage share device

1.1. Add Device Share

1.1.1. Add Multiple Device Sharing (coverage)

Sharing multiple devices to users will override all previous user sharing

Declaration

void addShare(long homeId, String countryCode, final String userAccount, ShareIdBean bean, boolean autoSharing, final ITuyaResultCallback<SharedUserInfoBean> callback);

Parameters

Parameter Description
homeId device home id
countryCode share member country code
userAccount share member user account
bean share device id list
autoSharing auto sharing
callback callback, including sharing success or failure, cannot be null

What's more, the data structure of ShareIdBean is as follows:

Parameter Type Description
devIds List<String> share device id list
meshIds List<String> share mesh id list

Example

TuyaHomeSdk.getDeviceShareInstance().addShare(homeId, countryCode, userAccount,
                shareIdBean, autoSharing, new ITuyaResultCallback<SharedUserInfoBean>() {
                    @Override
                    public void onSuccess(SharedUserInfoBean sharedUserInfoBean) {}
                    @Override
                    public void onError(String errorCode, String errorMsg) {}
                });

1.1.2. Add Shares (new, not overwriting old Shares)

Sharing multiple devices to users will add the devices to all user sharing. If you have previously shared the device with a specified user, you can obtain the target user id through the following getting Shared Relationships API, and then use this method to quickly share the device with the user.

Declaration

void addShareWithMemberId(long memberId,List<String> devIds,IResultCallback callback);

Parameters

Parameter Description
memberId share user member id
devIds share device id list
callback Callback, including sharing success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().addShareWithMemberId(userId, devIdList, new IResultCallback() {
            @Override
            public void onError(String errorCode, String errorMsg) {
            }
            @Override
            public void onSuccess() {
            }
});

1.1.3. Device Add Sharing

Sharing single or multiple devices to users will add the devices to all user shareing

Declaration


void addShareWithHomeId(long homeId, String countryCode, String userAccount, List<String> devIds, ITuyaResultCallback<SharedUserInfoBean> callback);

Parameters

Parameters Description
homeId device home id
countryCode share member country code
userAccount share member user account
devIds share device id list
callback Callback, including sharing success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().addShareWithHomeId(homeId, countryCode,
        userAccount, devsIdList, new ITuyaResultCallback<SharedUserInfoBean>() {
            @Override
            public void onSuccess(SharedUserInfoBean sharedUserInfoBean) {
            }

            @Override
            public void onError(String errorCode, String errorMsg) {                       
            }
});

1.2. Getting Shared Relationships

1.2.1. Get List of All Active Shared Users in the Home

Declaration

void queryUserShareList(long homeId, final ITuyaResultCallback<List<SharedUserInfoBean>> callback);

Parameters

Parameter Description
homeId home id
callback callback, including success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().queryUserShareList(homeId, new ITuyaResultCallback<List<SharedUserInfoBean>>() {
            @Override
            public void onSuccess(List<SharedUserInfoBean> sharedUserInfoBeans) {}
            @Override
            public void onError(String errorCode, String errorMsg) {}
        });

1.2.2. Get List of All Shared Uers Received

Declaration

void queryShareReceivedUserList(final ITuyaResultCallback<List<SharedUserInfoBean>> callback);

Parameters

Parameter Description
callback callback, including success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().queryShareReceivedUserList(new ITuyaResultCallback<List<SharedUserInfoBean>>() {
    @Override
    public void onSuccess(List<SharedUserInfoBean> sharedUserInfoBeans) {
    }
    @Override
    public void onError(String errorCode, String errorMsg) {
    }
});

1.2.3. Obtaining User-shared Data that is Actively Shared by a Single User

Declaration

void getUserShareInfo(long memberId, final ITuyaResultCallback<ShareSentUserDetailBean> callback);

Parameters

Parameter Description
memberId share member id
callback callback, including success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().getUserShareInfo(mRelationId, new ITuyaResultCallback<ShareSentUserDetailBean>() {
                @Override
                public void onSuccess(ShareSentUserDetailBean shareSentUserDetailBean) {}
                @Override
                public void onError(String errorCode, String errorMsg) {}
            });

1.2.4. Getting Shared Data from a Single Recipient

Declaration

void getReceivedShareInfo(long memberId, final ITuyaResultCallback<ShareReceivedUserDetailBean> callback);

Parameters

Parameter Description
memberId member id
callback callback, including success or failure, cannot be null

Example

 TuyaHomeSdk.getDeviceShareInstance().getReceivedShareInfo(mRelationId, new ITuyaResultCallback<ShareReceivedUserDetailBean>() {
                @Override
                public void onSuccess(ShareReceivedUserDetailBean shareReceivedUserDetailBean) {}
                @Override
                public void onError(String errorCode, String errorMsg) {}
            });

1.2.5. Get a Single Device Shared User List

Declaration

void queryDevShareUserList(String devId, final ITuyaResultCallback<List<SharedUserInfoBean>> callback);

Parameters

Parameter Description
devId device id
callback callback, including success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().queryDevShareUserList(mDevId, new ITuyaResultCallback<List<SharedUserInfoBean>>() {
        @Override
        public void onError(String errorCode, String errorMsg) {}
        @Override
        public void onSuccess(List<SharedUserInfoBean> shareUserBeen) {}
    });

1.2.6. Who Shares Access Devices

Declaration

void queryShareDevFromInfo(String devId, final ITuyaResultCallback<SharedUserInfoBean> callback);

Parameters

Parameter Description
devId receive share device id
callback callback, including success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().queryShareDevFromInfo(devId, new ITuyaResultCallback<SharedUserInfoBean>() {
            @Override
            public void onSuccess(SharedUserInfoBean result) {
            }
            @Override
            public void onError(String errorCode, String errorMessage) {
            }
        });

1.3. Remove Sharing

1.3.1. Delete Active Sharers

The sharer deletes all shared relationships with this user through memberId (user dimension delete)

Declaration

void removeUserShare(long memberId, IResultCallback callback);

Parameters

Parameter Description
memberId share memer id
callback callback, including delete success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().removeUserShare(memberId, new IResultCallback() {
    @Override
    public void onError(String code, String error) {
    }
    @Override
    public void onSuccess() {
    }
})

1.3.2. Delete Receiving Sharer

The shared party obtains the information of all shared devices of this user through memberId

Declaration

void removeReceivedUserShare(long memberId, IResultCallback callback);

Parameters

Parameter Description
memberId revice share member id
callback callback, including delete success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().removeReceivedUserShare(memberId, new IResultCallback() {
    @Override
    public void onError(String code, String error) {
    }
    @Override
    public void onSuccess() {
    }
})

1.3.3. Single Device Remove Sharing

Declaration

void disableDevShare(String devId, long memberId, IResultCallback callback);

Parameters

Parameter Description
memberId share member id
devId share device id
callback callback, including delete success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().disableDevShare (devId, memberId, new IResultCallback() {
    @Override
    public void onError(String code, String error) {
    }
    @Override
    public void onSuccess() {
    }
});

1.3.4. Remove Shared Devices Received

Declaration

void removeReceivedDevShare(String devId, IResultCallback callback);

Parameters

Parameter Description
devId reviced device id
callback callback, including delete success or failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().removeReceivedDevShare(devId,new IResultCallback() {
    @Override
    public void onError(String code, String error) {}
    @Override
    public void onSuccess() {}
})

1.4. Modify Note Name

1.4.1. Modify the nickname of the active sharer

The sharer modifies the remark name of the person being shared. If you share the device with other people, you can modify the remark name of the person.

Declaration

void renameShareNickname(long memberId, String name, IResultCallback callback);

Parameters

Parameters Description
memberId share member id
name new name
callback callback, including modification success and failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().renameShareNickname(mRelationId, inputText, new IResultCallback() {
                @Override
                public void onError(String s, String s1) {}
                @Override
                public void onSuccess() {}
            });

1.4.2. Modify the Nickname of the Recipient Sharer

Declaration

void renameReceivedShareNickname(long memberId, String name, IResultCallback callback);

Parameters

Parameters Description
memberId revice share member id
name new name
callback callback, including modification success and failure, cannot be null

Example

TuyaHomeSdk.getDeviceShareInstance().renameReceivedShareNickname(mRelationId, inputText, new IResultCallback() {
                @Override
                public void onError(String s, String s1) {}
                @Override
                public void onSuccess() {}
            });

results matching ""

    No results matching ""