Gyroscope and Visual Robot Vacuums

Last Updated on : 2023-05-22 06:38:30download

Common API methods

Common API methods are called to process streaming data. For more information, see Common API methods.

Query the latest cleaning task

API name

tuya.m.device.media.latest

Version

v2.0

Request parameter

Field name Type Description
devId String The device ID.
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 returned entries in total. The value is 500.

Response parameter

Field name Type Description
devId String The device ID.
startRow String The index for paged query.
dataList Array The streaming data.
subRecordId String The ID of the cleaning task.
hasNext BOOL Indicates whether the next page is included.

Sample response

{
	"devId":"6ccdd506b7186ee85avntm",
	"startRow":"mtnva58ee6817b605ddcc6_35_1535629239586",
	"dataList":[
		"373702373700",
		"383702383802373901383901383800",
		"373802373901373800",
		"373802363901363801373800",
		"373702373602373600",
		"373502373500",
		"373502373402373301363301373400",
		"363502363500",
		"363502363500"
	],
	"subRecordId":35,
	"hasNext":true,
	"startTime":1535629049,
	"endTime":1535629244,
	"status":2
}

Query historical data of cleaning tasks

API name

tuya.m.sweeper.cleaning.history.get

Version

v1.0

Request parameter

Field name 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.

Response parameter

Field name 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 Platform.
gmtCreate long The time when the cleaning record was created.
value String The information about the map. The value is returned after subRecordId is parsed.
uuid String The device ID.

Sample response

{
	"recordId":"162992AAXKaZCdL2tDvVcWYecT9AA9630150",
	"gid":38498424,
	"dpId":15,
	"gmtCreate":1629929630203,
	"value":"20210826052504804100145",
	"uuid":"ecc8c633ef1d9ede"
}

Query the details of a cleaning task

API name

tuya.m.device.media.detail

Version

v2.0

Request parameter

Field name 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 returned entries in total. The value is 500.

Data point parsing protocol

Record time Cleaning time Cleaning area subRecordId Example Description
Yes Yes Yes Yes 20200319202500300200123
  • The panel displays the timestamp when the record was reported by the microcontroller unit (MCU).
  • Tap the record to show the map.
No Yes Yes Yes 00300200123
  • The panel displays the timestamp when the record was reported to the cloud.
  • Tap the record to show the map.
Yes Yes Yes No 202003192025003002
  • The panel displays the timestamp when the record was reported by the MCU.
  • Tap the record without showing the map.
No Yes Yes No 003002
  • The panel displays the timestamp when the record was reported to the cloud.
  • Tap the record without showing the map.

Response parameter

Field name Type Description
devId String The device ID.
startRow String The index for paged query.
dataList Array The streaming data.
subRecordId String The ID of the cleaning task.
hasNext BOOL Indicates whether the next page is included.

Sample response

{
	"devId":"6ccdd506b7186ee85avntm",
	"startRow":"mtnva58ee6817b605ddcc6_31_1535622776561",
	"dataList":[
		"3e3f02403e013e3f00",
		"3f3f024040013f3f00",
		"3f3f02403f014040013f3f00",
		"3f40024140014040013f3f024041013f41013f3f00",
		"3f3f024040014041013f41013f3f00"
	],
	"subRecordId":31,
	"hasNext":true,
	"startTime":1535621566,
	"endTime":1535623017,
	"status":2
}

Delete historical cleaning tasks

API name

tuya.m.sweeper.cleaning.history.delete

Version

v1.0

Request parameter

Field name Type Description
devId String The device ID.
uuid Integer The ID of the cleaning task.

Sample response

{
	"result":true,
	"success":true,
	"status":"ok",
	"t":1557740732829
}

Functional APIs

Data flow

Gyroscope and Visual Robot Vacuums

Overview

Powered by Tuya (PBT) gyroscope or visual robot vacuums transmit map data through streaming channels. The TuyaSmartSweeperDeviceDelegate delegate protocol is implemented to receive the callback of received map streaming data.

Class name Description
TuyaSmartSweepDevice The class of PBT robot vacuums.

Subscribe to map streaming data

API description

Subscribes to map streaming data of a robot vacuum.

- (void)subscribeDeviceDataTransfer;

Example

ObjC:

- (void)subscribeDevice {

	[self.sweeperDevice subscribeDeviceDataTransfer];
}

Swift:

func subscribeDevice() {
	sweeperDevice?.subscribeDeviceDataTransfer()
}

Unsubscribe from map streaming data

API description

Unsubscribes from map streaming data of a robot vacuum.

- (void)unsubscribeDeviceDataTransfer;

Example

ObjC:

- (void)unsubscribeDevice {

	[self.sweeperDevice unsubscribeDeviceDataTransfer];
}

Swift:

func unsubscribeDevice() {
	sweeperDevice?.unsubscribeDeviceDataTransfer()
}

Execute a streaming data callback

API description

Executes the callback of real-time streaming data reported by a robot vacuum.

- (void)sweeperDevice:(TuyaSmartSweeperDevice *)sweeperDevice didReceiveStreamData:(NSData *)data;

Parameter description

Parameter Description
sweeperDevice The instance object of TuyaSmartSweeperDevice.
data The streaming data of NSData type. Bits 0 to 3 indicate subRecordId of a map, and bits 4 to 12 are not business data and will neither be parsed.
Note that actual map data is indicated starting from Bit 13. Every three bits create a map point, including the x-coordinate, y-coordinate, and point type of the map point.

Example

ObjC:

self.sweeperDevice = [TuyaSmartSweeperDevice deviceWithDeviceId:<#devId#>];
self.sweeperDevice.delegate = self;

// Implements the delegate method.
- (void)sweeperDevice:(TuyaSmartSweeperDevice *)sweeperDevice didReceiveStreamData:(NSData *)data {

}

Swift:

sweeperDevice = TuyaSmartSweeperDevice.init(deviceId: "your_devId")
sweeperDevice?.delegate = self

func sweeperDevice(_ sweeperDevice: TuyaSmartSweeperDevice, didReceiveStreamData data: Data) {

}