Last Updated on : 2022-02-17 05:45:38download
A project is an independent unit that is managed by a user. Areas and devices must be assigned to a user before they can be managed.
One or more projects can be created for a user. The maximum number of projects that can be created for a user depends on the plan purchased by the user. A newly created user is not assigned projects. Projects must be created after login to enable follow-up operations.
Indoor project: visual management of devices on the building plan. Recommended for simple scenarios where the project address can be simply described in text. It is suitable for office buildings, shopping malls, and other similar projects.
Outdoor project: accurate positioning of devices by GIS maps, recommended for larger areas and scattered device scenarios. The project region is specified with the country code combined with a level-1 administrative code. Project subordinate areas are displayed by marking points on the map. [The current project type is only available for the advanced version of the brand to open the account to create permission]. It is suitable for outdoor street lights, charging piles and other projects.
Get data configuration under indoor/outdoor project type.
Interface description
void getProjectConfigList(ITuyaResultCallback<List<LightingProjectConfigsBean>> callback);
LightingProjectConfigsBean description
Project configuration information class
Parameters | Type | Description |
---|---|---|
projectType | int | Current project type: 0 - indoor project, 1 - outdoor project |
projectTypeName | String | The name of the current project type |
projectIconUrl | String | The icon for the current project type |
spaceAttributes | List |
Hierarchical list of areas |
AreaConfig description
Area hierarchy information class
Parameters | Type | Description |
---|---|---|
id | int | Area hierarchy ID |
name | String | The name of the area hierarchy, such as campus-buildings-floor-rooms |
iconUrl | String | Area level icon |
Example
TuyaCommercialLightingProject.getLightingProjectManager().getProjectConfigList(new ITuyaResultCallback<List< LightingProjectConfigsBean>>() {
@Override
public void onSuccess(List<LightingProjectConfigsBean> result) {
if (null ! = result) {
iProjectIndexView.getProjectConfigListSuccess(result);
}
}
@Override
public void onError(String errorCode, String errorMessage) {
Log.e(TAG, "getProjectConfigList onError: errorCode=" + errorMessage);
iProjectIndexView.getProjectConfigListError();
}
});
Interface description
Create a new project that can be an indoor project and an outdoor project.
void createProject(
int projectType,
String name,
String leaderName,
String leaderMobile,
String detail,
String regionLocationId,
ITuyaHomeResultCallback callback);
Parameters
Parameter | Description | Required |
---|---|---|
projectType | The project type (valid values: 0 : default indoor project, and 1 : outdoor project). The type ID can be obtained from the response of ProjectConfigurationInformation method |
yes |
name | project name | yes |
leaderName | project leader | yes |
leaderMobile | contact information | yes |
detail | detail address Indoor project type must be passed to describe the detailed address Outdoor project type must be passed to describe the outdoor project location, we recommend to check the region stitching Example: Zhejiang Province, China, California, and USA. |
yes |
regionLocationId | Region ID split by “,” Outdoor project type must be passed to describe an outdoor project location China region: level-1 administrative region, other regions: country + level-1 administrative region Example Indoor Project Type must be passed to describe the location of the outdoor project China: level-1 administrative district, other districts: country code + level-1 administrative district Example |
Example
TuyaCommercialLightingProject.getLightingProjectManager().createProject(projectType, projectName, leaderName, leaderMobile, detailAddress, regionId, new ITuyaHomeResultCallback() {
@Override
public void onSuccess(HomeBean homeBean) {
if (null == mProjectAddView) {
return;
}
mProjectAddView.doSaveSuccess();
}
@Override
public void onError(String s, String s1) {
if (null == mProjectAddView) {
return;
}
mProjectAddView.doSaveFailed(s1);
}
});
Interface description
Edit project information
void updateProjectInfo(
String name,
String regionLocationId,
String detail,
String leaderName,
String leaderMobile,
IResultCallback callback);
Parameters
Parameter | Description | Required |
---|---|---|
projectId | project ID | yes |
name | project name | yes |
regionLocationId | Multiple regionId split by “,” Outdoor project type must be passed to describe the location of the outdoor project China region: level-1 administrative region, other regions: country + level-1 administrative region Example: Zhejiang id; US id,California id Indoor Project Type This field must be passed blank |
no |
detail | detail address. Indoor project type must be passed to describe the detailed address Outdoor project type must be passed to describe the location of the outdoor project, it is recommended to check the regional stitching Example: Zhejiang Province, China; California, USA, etc. |
yes |
leaderName | project leader | yes |
leaderMobile | leader contact | yes |
Example
TuyaCommercialLightingProject.newProjectInstance(projectId).updateProjectInfo(mHomeBean.getHomeId(), mHomeBean.getName(),mHomeBean . getLeaderName(), mHomeBean.getLeaderMobile(), regionId, content, new IResultCallback() {
@Override
public void onError(String code, String error) {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.showToast(error);
}
@Override
public void onSuccess() {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.updateAddressDetail(content);
}
});
Interface description
Deletes a project that has been created. After a project is deleted, all data will be cleared and the added devices will be unbundled and reset.
Deleting a project is a high-risk operation and requires a password to ensure security. So the project deletion method will handle the password check internally, and entering the correct password will directly invoke the delete operation. If a risk alert pop-up window and other related interactions are required, implement them before the password is entered.
void deleteProjectWithPassword(String password, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
projectId | The ID of the project to be deleted. |
key | Get key by password (user system: getKeyFromPassword) |
password | The password of the current account |
Example
TuyaCommercialLightingProject.newProjectInstance(projectId).deleteProjectWithPassword(mIProjectInfoView.getProjectId(), password, new IResultCallback() {
@Override
public void onError(String s, String s1) {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.showToast(s1);
}
@Override
public void onSuccess() {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.doRemoveView(true);
}
});
Interface description
Returns a list of projects that have been created.
void getProjectList(ITuyaGetHomeListCallback callback);
Example
TuyaCommercialLightingProject.getLightingProjectManager().getProjectList(new ITuyaGetHomeListCallback() {
@Override
public void onSuccess(List<HomeBean> list) {
Log.i(TAG, "queryProjectList onSuccess: " + JSON.toJSONString(list));
if (null == iProjectIndexView.getContext()) {
return;
}
if (CollectionUtils.isEmpty(list)) {
iProjectIndexView.showProjectEmptyView();
} else {
iProjectIndexView.setProjectList(list);
}
}
@Override
public void onError(String s, String s1) {
Log.e(TAG, "queryProjectList onError: errorCode=" + s);
}
});
Interface description
Returns the details of the specified project.
void getProjectDetail(ITuyaHomeResultCallback callback);
Parameters
Parameter | Description |
---|---|
projectId | projectId, you can get the data returned by [Get Project List](# Get Project List), take the projectId |
Example
TuyaCommercialLightingProject.newProjectInstance(long projectId).getProjectDetail(mIProjectInfoView.getProjectId(), new ITuyaHomeResultCallback() {
@Override
public void onSuccess(HomeBean homeBean) {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.setProjectData(homeBean);
}
@Override
public void onError(String s, String s1) {
if (null == mIProjectInfoView) {
return;
}
mIProjectInfoView.showToast(s1);
}
});
Interface description
According to the mappings between user accounts and the countries and regions, the following countries and regions are supported: China (China), the United States (the United States, Japan, Hong Kong, China), Europe (Australia). Three data regions with six countries and one region. The data regions supported countries are dynamically updated, subject to the actual responses. If you have new needs, contact the account manager.
void getRegionList(ITuyaResultCallback<List<LightingRegionListBean>> listener);
LightingRegionListBean field descriptions:
Field | Type | Description |
---|---|---|
locationId | String | Current Region ID |
name | String | The name of the current locale, multilingual is supported. |
pinyinInitials | String | The first letter of the region name. Chinese: pinyin initials, other: English initials This field is mainly used for custom sorting/indexing. |
children | List |
Sub-regions under the current region. For example: the first-level administrative region under the country. |
Example
TuyaCommercialLightingRegion.getRegionManager().getRegionList(new ITuyaResultCallback<List<LightingRegionListBean>>() {
@Override
public void onSuccess(List<LightingRegionListBean> result) {
if (result ! = null) {
mRegionListView.getRegionListSuccess(result);
}
}
@Override
public void onError(String errorCode, String errorMessage) {
mRegionListView.getRegionListError(errorMessage);
}
});
Interface description
Precondition: the [Get Data Area Country List](# Get Data Area Country List) method has been called once. Otherwise this method returns null.
Usage scenario: The list data basically does not change. This allows data caching to be implemented. This method is to read the list data from the cache.
List<LightingRegionListBean> getRegionListFromCache();
Example
List<LightingRegionListBean> result = TuyaCommercialLightingRegion
.getRegionManager()
.gerRegionListFromCache();
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback