Last Updated on : 2023-05-22 06:38:30download
Sweeper SDK provides HTTP and HTTPS API requests and real-time channels to enable data queries. Historical records and other data can be queried or deleted by HTTP and HTTPS API requests. The cleaning data transmitted from and to robot vacuums can be queried by the registration of listeners on real-time channels.
Smart Life App SDK provides common HTTP and HTTPS methods. In the API requests, the method name, version number, and request parameters are required.
Access to API
TuyaHomeSdk.getRequestInstance()
Example
public interface ITuyaSmartRequest {
/**
*
* @param apiName The API name.
* @param version The version number.
* @param postData Sends data.
* @param callback The callback.
* @param object The data structure that receives the callback data, for example, a Java Bean.
*/
<T> void requestWithApiName(String apiName, String version, Map<String, Object> postData, Class<T> object, final ITuyaDataCallback<T> callback);
<T> void requestWithApiNameWithoutSession(String apiName, String version, Map<String, Object> postData, Class<T> object, final ITuyaDataCallback<T> callback);
void onDestroy();
}
Request parameters
apiName: tuya.m.device.media.latest
version: 2.0
postData:
{
"devId": "xxx",
"start":"",
"size": 500
}
Sample response
{
"devId": "xxx",
"startRow": "mtnva58ee6817b605ddcc6_35_1535629239586",
"dataList": [ "373702373700", "383702383802373901383901383800"],
"subRecordId": 35,
"hasNext": true,
"startTime": 1535629049,
"endTime": 1535629244,
"status": 2
}
Request parameters
apiName: tuya.m.sweeper.cleaning.history.get
version: 1.0
postData:
Field | Type | Description |
---|---|---|
devId | String | The device ID. |
offset | Integer | The number of entries starting from which entries are returned. |
limit | Integer | The maximum number of entries returned on each page. |
startTime | Long | The start time of the time range to be queried. |
endTime | Long | The end time of the time range to be queried. |
Sample response
{
"datas":[{
"recordId":"162992AAXKaZCdL2tDvVcWYecT9AA9630150",
"gid":38498424,
"dpId":15,
"gmtCreate":1629929630203,
"value":"20210826052504804100145",
"uuid":"ecc8c633ef1d9ede"
}],
"totalCount":1
}
Field | Type | Description |
---|---|---|
recordId | String | The map ID. |
gid | int | The home group ID. |
dpId | int | The data point (DP) ID generated on the Tuya IoT Development Platform. |
gmtCreate | long | The time when the cleaning record was created. |
value | String | The information about the map. The value is used to parse subRecordId . |
uuid | String | The device ID. |
Request parameters
apiName: tuya.m.device.media.detail
version: 2.0
postData:
{
"devId": "xxx",
"subRecordId": 31,
"start":"",
"size": 500
}
Field | Type | Description |
---|---|---|
devId | String | The device ID. |
subRecordId | Integer | The ID of the cleaning task to be queried. Parse the value parameter of the historical cleaning tasks to get the ID. The parsing rules vary depending on different data lengths. The following table describes the rules. |
start | String | The start position. The value in the first request is empty. In the follow-up requests, the value of startRow in the last response is required. |
size | Integer | The maximum number of entries to be returned in each call. |
Protocol for parsing value
Record time 12 digits |
Cleaning time 3 digits |
Cleaning area 3 digits |
subRecordId 5 digits |
Example | Description |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | 20200319202500300200123 |
|
No | Yes | Yes | Yes | 00300200123 |
|
Yes | Yes | Yes | No | 202003192025003002 |
|
No | Yes | Yes | No | 003002 |
|
Sample response
{
"devId": "xxx",
"startRow": "mtnva58ee6817b605ddcc6_31_1535622776561",
"dataList": ["3e3f02403e013e3f00", "3f3f024040013f3f00"],
"subRecordId": 31,
"hasNext": true,
"startTime": 1535621566,
"endTime": 1535623017,
"status": 2
}
Field | Type | Description |
---|---|---|
startRow | String | The value of Start passed in the next API request. |
subRecordId | Integer | The ID of the cleaning task. |
startTime | String | Query start time |
endTime | String | The end time. |
hasNext | Boolean | Specifies whether to return the next page. |
Up to 100 entries can be deleted in each call.
Request parameters
apiName: tuya.m.sweeper.cleaning.history.delete
version: 1.0
postData:
{
"devId": "xxx",
"uuid": "15607600058B81A6C4A0273FDD61091D0B02403848501,
15607600058B81A6C4A0273FDD61091D0B0240384850"
}
The uuid
parameter in the preceding example for JSON is the unique ID of each cleaning task. This parameter is not the uuid
parameter of a device but equal to the recordId
parameter of a historical task.
Sample response
{
"result":true,
"success":true,
"status":"ok",
"t":1557740732829
}
Real-time channels can be registered to listen for reported device data streams. Arrays are returned in the response and parsed into required data, such as the x-coordinate, y-coordinate, and color values, using the device protocol.
Access to API: TuyaHomeSdk.getTransferInstance();
API description
void registerTransferDataListener(ITuyaDataCallback<TransferDataBean> callback);
Example
TuyaHomeSdk.getTransferInstance().registerTransferDataListener(new ITuyaDataCallback<TransferDataBean>() {
@Override
public void onSuccess(TransferDataBean result) {
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TransferDataBean
Field | Type | Description |
---|---|---|
data | byte[] |
|
devId | String | The device ID. |
API description
void unRegisterTransferDataListener(ITuyaDataCallback<TransferDataBean> callback);
Example
TuyaHomeSdk.getTransferInstance().unRegisterTransferDataListener(this);
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback