1. Home Relationship Management

Get the family list, family management, room and equipment management under the family and information monitoring, etc.

HomeBean description

Parameters Type Description
name String The home name
lon double The home lon
lat double The home lat
geoName String The home location name
homeId long The home Id
admin boolean Administrator status
rooms List<RoomBean> All the rooms
deviceList List<DeviceBean> All the devices
groupList List<GroupBean> All the groups
meshList List<BlueMeshBean> All of the mesh devices
sharedDeviceList List<DeviceBean> Shared devices received
sharedGroupList List<GroupBean> Shared groups received
homeStatus int The home status (1:to be accepted 2:accepted 3:reject)

1.1. Get Family List

Declaration

void queryHomeList(ITuyaGetHomeListCallback callback)

Parameters

Parameters Description
callback Result callback

Example

TuyaHomeSdk.getHomeManagerInstance().queryHomeList(new ITuyaGetHomeListCallback() {
        @Override
        public void onError(String errorCode, String error) {
            // do something
        }
        @Override
        public void onSuccess(List<HomeBean> homeBeans) {
            // do something
        }
    });

1.2. Create family

Declaration

void createHome(String name, double lon, double lat, String geoName, List rooms, ITuyaHomeResultCallback callback)

Parameters

Parameters Description
name Family name
lon longitude
lat latitude
geoName Home location name
rooms Room list
callback Result callback

Example

TuyaHomeSdk.getHomeManagerInstance().createHome(name, lon, lat, geoName, rooms, new ITuyaHomeResultCallback() {
        @Override
        public void onError(String errorCode, String errorMsg) {
            // do something
        }
        @Override
        public void onSuccess(HomeBean bean) {
            // do something
        }
    });

1.3. Change of home information

1.3.1. register or unRegister Listener

Change of registered home information includes: adding and removing homes, information change, change of shared lists and monitoring of successfully server connection.

Declaration

void registerTuyaHomeChangeListener(ITuyaHomeChangeListener listener);

Parameters

Parameters Description
listener Monitor

Example

ITuyaHomeChangeListener listener = new ITuyaHomeChangeListener() {
        @Override
        public void onHomeInvite(long homeId, String homeName) {
            // do something
        }
        @Override
        public void onHomeRemoved(long homeId) {
            // do something
        }
        @Override
        public void onHomeInfoChanged(long homeId) {
            // do something
        }
        @Override
        public void onSharedDeviceList(List<DeviceBean> sharedDeviceList) {
            // do something
        }
        @Override
        public void onSharedGroupList(List<GroupBean> sharedGroupList) {
            // do something
        }
        @Override
        public void onServerConnectSuccess() {
            // do something
        }
        @Override
        public void onHomeAdded(long homeId) {
            // do something
        }
    };
TuyaHomeSdk.getHomeManagerInstance().registerTuyaHomeChangeListener(listener);

1.3.2. Deregistered the information Change of a home.

Declaration

void unRegisterTuyaHomeChangeListener(ITuyaHomeChangeListener listener)

Parameters

Parameters Description
listener Monitor

Example

ITuyaHomeChangeListener listener = new ITuyaHomeChangeListener() {
        @Override
        public void onHomeInvite(long homeId, String homeName) {
            // do something
        }
        @Override
        public void onHomeRemoved(long homeId) {
            // do something
        }
        @Override
        public void onHomeInfoChanged(long homeId) {
            // do something
        }
        @Override
        public void onSharedDeviceList(List<DeviceBean> sharedDeviceList) {
            // do something
        }
        @Override
        public void onSharedGroupList(List<GroupBean> sharedGroupList) {
            // do something
        }
        @Override
        public void onServerConnectSuccess() {
            // do something
        }
        @Override
        public void onHomeAdded(long homeId) {
            // do something
        }
    };
TuyaHomeSdk.getHomeManagerInstance().registerTuyaHomeChangeListener(listener);
// ...
TuyaHomeSdk.getHomeManagerInstance().unRegisterTuyaHomeChangeListener(listener);

1.3.3. Callback of MQTT Service Connection Success

Declaration

void onServerConnectSuccess()

Example

ITuyaHomeChangeListener listener = new ITuyaHomeChangeListener() {
        @Override
        public void onHomeInvite(long homeId, String homeName) {
            // do something
        }
        @Override
        public void onHomeRemoved(long homeId) {
            // do something
        }
        @Override
        public void onHomeInfoChanged(long homeId) {
            // do something
        }
        @Override
        public void onSharedDeviceList(List<DeviceBean> sharedDeviceList) {
            // do something
        }
        @Override
        public void onSharedGroupList(List<GroupBean> sharedGroupList) {
            // do something
        }
        @Override
        public void onServerConnectSuccess() {
            // do something
        }
        @Override
        public void onHomeAdded(long homeId) {
            // do something
        }
    };

TuyaHomeSdk.getHomeManagerInstance().registerTuyaHomeChangeListener(listener);
// ...
TuyaHomeSdk.getHomeManagerInstance().unRegisterTuyaHomeChangeListener(listener);

2. Family Management

2.1. Get Family Details

Obtain all data under the family, including equipment, groups, rooms, etc

Declaration

void getHomeDetail(ITuyaHomeResultCallback callback)

Parameters

Parameters Description
callback Callback to get results

Example

TuyaHomeSdk.newHomeInstance(10000).getHomeDetail(new ITuyaHomeResultCallback() {
        @Override
        public void onError(String errorCode, String errorMsg) {
            // do something
        }
        @Override
        public void onSuccess(HomeBean bean) {
            // do something
        }
    });

2.2. Update Family Information

Declaration

void updateHome(String name, double lon, double lat, String geoName, List rooms, boolean overWriteRoom, IResultCallback callback)

Parameters

Parameters Description
name Family name
lon Longitude of current family
lat Latitude of the current family
geoName Address of geographical location
rooms Room information
overWriteRoom Whether to overwrite the existing room
callback Result callback

Example

TuyaHomeSdk.newHomeInstance(10000).updateHome(name, lon, lat, geoName, rooms, overWriteRoom, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

2.3. Disband Family

Declaration

void dismissHome(IResultCallback callback)

Parameters

Parameters Description
callback Result callback

Example

TuyaHomeSdk.newHomeInstance(10000).dismissHome(new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

2.4. Add Room

Declaration

void addRoom(String name, ITuyaRoomResultCallback callback)

Parameters

Parameters Description
name Room name
callback Result callback

Example

TuyaHomeSdk.newHomeInstance(10000).addRoom(name, new ITuyaRoomResultCallback() {
        @Override
        public void onError(String errorCode, String errorMsg) {
            // do something
        }
        @Override
        public void onSuccess(RoomBean bean) {
            // do something
        }
    });

2.5. Remove Room

Declaration

void removeRoom(long roomId, IResultCallback callback)

Parameters

Parameters Description
roomId Room ID
callback Result callback

Example

TuyaHomeSdk.newHomeInstance(10000).removeRoom(roomId, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

2.6. Sorting Rooms

Declaration

void sortRoom(List<Long> idList, IResultCallback callback)

Parameters

Parameters Description
idList Room ID list
callback Result callback

Example

TuyaHomeSdk.newHomeInstance(10000).sortRoom(idList, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

3. Family Member Management

3.1. Add Home Member

Declaration

The field autoAccept in MemberWrapperBean was used to control if the member added should accept the invaitation. If the value was false, the added member shuold call processInvitation() and then he/she can join the family.

void addMember(MemberWrapperBean memberWrapperBean, ITuyaDataCallback<MemberBean> callback)

Parameters

Parameters Description
memberWrapperBean Member information

Example

TuyaHomeSdk.getMemberInstance().addMember(memberWrapperBean, new ITuyaDataCallback<MemberBean>() {
        @Override
        public void onError(String errorCode, String errorMessage) {
            // do something
        }
        @Override
        public void onSuccess(MemberBean result) {
            // do something
        }
    });

3.2. Delete Home Member

Declaration

void removeMember(long memberId, IResultCallback callback)

Parameters

Parameters Description
memberId Member ID

Example

TuyaHomeSdk.getMemberInstance().removeMember(memberId, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

3.3. Query the Member List Under Home

Declaration

void queryMemberList(long mHomeId, ITuyaGetMemberListCallback callback)

Parameters

Parameters Description
mHomeId Family ID

Example

TuyaHomeSdk.getMemberInstance().queryMemberList(mHomeId, new ITuyaGetMemberListCallback() {
        @Override
        public void onError(String errorCode, String error) {
            // do something
        }
        @Override
        public void onSuccess(List<MemberBean> memberBeans) {
            // do something
        }
    });

3.4. Update Member Information

Declaration

void updateMember(MemberWrapperBean memberWrapperBean, IResultCallback callback)

Parameters

Parameters Description
memberWrapperBean Member information

Example

TuyaHomeSdk.getMemberInstance().updateMember(memberWrapperBean, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

3.5. Accept or Refuse To Join the Family

Declaration

void processInvitation(long homeId, boolean action, IResultCallback callBack)

Parameters

Parameters Description
homeId Family ID
action Accept \/ reject

Example

TuyaHomeSdk.getMemberInstance().processInvitation(homeId, action, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

3.6. Sort Groups or Devices in Your Home

Declaration

void sortDevInHome(String homeId, List<DeviceAndGroupInHomeBean> list, IResultCallback callback)

Parameters

Parameters Description
homeId Room ID
list Room or group liist. The list element DeviceAndGroupInHomeBean here contains two fields. The one is bizType, which is the target type to sort. You can refer to BizParentTypeEnum for details. Another is bizId, which is the id of target, for example, group id or device id.
callback result callback

Meanings of the enum BizParentTypeEnum:

  • LOCATION
  • MESH
  • ROOM
  • GROUP
  • DEVICE

Example

List<DeviceAndGroupInHomeBean> list = new ArrayList<>();
List<DeviceBean> deviceList = homeBean.getDeviceList();
List<GroupBean> groupList = homeBean.getGroupList();
for (GroupBean bean : groupList) {
    DeviceAndGroupInHomeBean deviceInRoomBean = new DeviceAndGroupInHomeBean();
    deviceInRoomBean.setBizId(bean.getDevId());
    deviceInRoomBean.setBizType(BizParentTypeEnum.GROUP.getType());
    list.add(deviceInRoomBean);
}
for (DeviceBean bean : deviceList) {
    DeviceAndGroupInHomeBean deviceInRoomBean = new DeviceAndGroupInHomeBean();
    deviceInRoomBean.setBizId(bean.getDevId());
    deviceInRoomBean.setBizType(BizParentTypeEnum.DEVICE.getType());
    list.add();
}
TuyaHomeSdk.newHomeInstance(10000).sortDevInHome(homeId, list, new IResultCallback() {
        @Override
        public void onSuccess() {
            // do something
        }
        @Override
        public void onError(String code, String error) {
            // do something
        }
    });

3.7. Log Off Monitoring of Information Changes Below Home

Declaration

void unRegisterHomeStatusListener(ITuyaHomeStatusListener listener)

Parameters

Parameters Description
listener Monitor

Example

// define a listener
ITuyaHomeStatusListener listener = new ITuyaHomeStatusListener() {
        @Override
        public void onDeviceAdded(String devId) {
            // do something
        }
        @Override
        public void onDeviceRemoved(String devId) {
            // do something
        }
        @Override
        public void onGroupAdded(long groupId) {
            // do something
        }
        @Override
        public void onGroupRemoved(long groupId) {
            // do something
        }
        @Override
        public void onMeshAdded(String meshId) {
            // do something
        }
    };
// register a listener somewhere
TuyaHomeSdk.newHomeInstance(10000).registerHomeStatusListener(listener);
// ...
// unregister a listener
TuyaHomeSdk.newHomeInstance(10000).unRegisterHomeStatusListener(listener);

4. Room Information Management

RoomBean

Parameters Type Description
roomId long Room id
name String Room name
deviceList List <DeviceBean> Devices of room
groupList List <GroupBean> Groups of room
displayOrder int Room display order

4.1. Update Room Name

Declaration

void updateRoom(String name, IResultCallback callback)

Parameters

Parameters Description
name New room name

Example

TuyaHomeSdk.newRoomInstance(10000).updateRoom(name, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

4.2. Add Device to a Room

Declaration

void addDevice(String devId, IResultCallback callback)

Parameters

Parameters Description
devId Device ID

Example

TuyaHomeSdk.newRoomInstance(10000).addDevice(devId, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

4.3. Remove Device from a Room

Declaration

void removeDevice(String devId, IResultCallback callback)

Parameters

Parameters Description
devId Device ID

Example

TuyaHomeSdk.newRoomInstance(10000).removeDevice(devId, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

4.4. Add Group in a Room

Declaration

void addGroup(long groupId, IResultCallback callback)

Parameters

Parameters Description
groupId Group ID

Example

TuyaHomeSdk.newRoomInstance(10000).addGroup(groupId, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

4.5. Remove Group in a Room

Declaration

void removeGroup(Long groupId, IResultCallback resultCallback)

Parameters

Parameters Description
groupId Group ID

Example

TuyaHomeSdk.newRoomInstance(10000).removeGroup(groupId, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

4.6. Remove Group or Device From Room

Declaration

void moveDevGroupListFromRoom(List list, IResultCallback callback)

Parameters

Parameters Description
list Group or device

Example

TuyaHomeSdk.newRoomInstance(10000).moveDevGroupListFromRoom(list, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

4.7. Sort Groups or Devices in a Room

Declaration

void sortDevInRoom(List<DeviceAndGroupInRoomBean> list, IResultCallback callback)

Parameters

Parameters Description
list Group or device

Example

TuyaHomeSdk.newRoomInstance(10000).sortDevInRoom(list, new IResultCallback() {
        @Override
        public void onError(String code, String error) {
            // do something
        }
        @Override
        public void onSuccess() {
            // do something
        }
    });

5. Home Weather

5.1. Get Home's Weather Simple Summary Parameters

Sush as state of weather(clear, cloudy, rainy, and so on),weather icon.

Declaration

void getHomeWeatherSketch(double lon,double lat,IIGetHomeWetherSketchCallBack callback);

Parameters

Parameters Description
lon longitude
lat latitude
callback callback

WeatherBean Description

Parameters Description
condition weather description
temp temperature
iconUrl weather icon
inIconUrl weather icon

Example

TuyaHomeSdk.newHomeInstance(mHomeId).getHomeWeatherSketch(120.075652,30.306265
  new IIGetHomeWetherSketchCallBack() {
    @Override
    public void onSuccess(WeatherBean result) {
    }
    @Override
    public void onFailure(String errorCode, String errorMsg) {
    }
  });

5.2. Get Home's Weather Summary Parameters with More Detail

Such as tempature, humidity, ultraviolet index, air quality.

Declaration

void getHomeWeatherDetail(int limit, Map<String,Object> unit, IGetHomeWetherCallBack callback);

Parameters

Parameters Description
limit list count
unit parameter unit
callback callback

More explanations about the unit:

key value
tempUnit Celsius:1
Fahrenheit:2

For example, when the unit of the data you want to obtain is Celsius unit:

Map<String,Object> units = new HashMap<>();
units.put("tempUnit",1);

Example

Map<String,Object> units = new HashMap<>();
units.put("tempUnit",1);

TuyaHomeSdk.newHomeInstance(mHomeId).getHomeWeatherDetail(10, units, new IGetHomeWetherCallBack() {
    @Override
    public void onSuccess(ArrayList<DashBoardBean> result) {

    }

    @Override
    public void onFailure(String errorCode, String errorMsg) {

    }
});

results matching ""

    No results matching ""