Standard Instruction Set

Last Updated on : 2022-09-05 07:28:29download

A standard instruction set is a set of control function instructions that can be sent by devices. The standard instruction set varies depending on the product category. The control instructions supported by a specified product form a subset of the standard instruction set of the product category. This series of documents provides the instruction set for certain product categories on the Tuya IoT Platform. The instruction sets for more products are being developed. If you have any requirements, you can submit a ticket to contact Tuya.

Terms and definitions

Term Definition
Standard instruction set A standard instruction set is a set of control function instructions that can be sent by devices.
Standard product category A standard product category provides a list of standardized product categories that can be controlled using the standard instruction set and the standard status set for a status query.
Standard status set A standard status set is the set of functional statuses that can be reported by the device to the cloud. A standard status set varies depending on the product category. The functional statuses supported by a specified product form a subset of the standard status set of the product category.
Product function A product function is a cloud control connection model defined by the Tuya IoT Platform for smart devices. It is used to explain the data interaction mode of each function of the device.

Things to note

  • The instruction set provided in this section is not completely consistent with the definition of product functions on the Tuya IoT Platform. The Tuya IoT Platform is integrated with the instructions of different products in the same category.
  • You only need to integrate with Tuya’s instruction set of the same category, before you can control different products of the same category.
  • If the returned standard product is an early product with a category code of qt, it might no longer be supported. If you need to integrate with it, please submit a ticket for confirmation.

Procedure

This section takes the electric pressure cooker in the Function Definition as an example to describe how to query the cloud function properties and status properties of smart devices.

Step 1: Query device function properties

You can refer to the sample request in this step to query the standard functional properties (or the instruction set) supported by your device and the status properties (or the status set) that can be reported. For more information about APIs, see Get the specifications and properties of the device.

  • The instruction set will be used as the code in the instruction to be sent.

  • The status set will be used to query the device status interface.

    If the returned result is empty, submit a ticket for confirmation.

Sample request

curl --request GET "https://openapi.tuyacn.com/v1.0/iot-03/devices/vdevo16**********035/specifications" --header "sign_method: HMAC-SHA256" --header "client_id: x37******************mmu0" --header "t: 1630599812793" --header "mode: cors" --header "Content-Type: application/json" --header "sign: 4979EC676FB3B7******************A0835B1CF46265B" --header "access_token: 5eb*********1371"

Sample response

{
"result": {
	"category": "dylg",
	"functions": [
	{
		"code": "switch",
		"type": "Boolean",
		"values": "{}"
	},
	{
		"code": "start",
		"type": "Boolean",
		"values": "{}"
	},
	{
		"code": "appointment_time",
		"type": "Integer",
		"values": "{\"unit\":\"min\",\"min\":0,\"max\":1440,\"scale\":0,\"step\":1}"
	},
	{
		"code": "cook_time",
		"type": "Integer",
		"values": "{\"unit\":\"min\",\"min\":0,\"max\":6000,\"scale\":0,\"step\":1}"
	},
	{
		"code": "warm_time",
		"type": "Integer",
		"values": "{\"unit\":\"min\",\"min\":30,\"max\":1440,\"scale\":0,\"step\":1}"
	}
	],
	"status": [
	{
		"code": "switch",
		"type": "Boolean",
		"values": "{}"
	},
	{
		"code": "start",
		"type": "Boolean",
		"values": "{}"
	},
	{
		"code": "appointment_time",
		"type": "Integer",
		"values": "{\"unit\":\"min\",\"min\":0,\"max\":1440,\"scale\":0,\"step\":1}"
	},
	{
		"code": "cook_time",
		"type": "Integer",
		"values": "{\"unit\":\"min\",\"min\":0,\"max\":6000,\"scale\":0,\"step\":1}"
	},
	{
		"code": "work_state",
		"type": "Enum",
		"values": "{\"range\":[\"idle\",\"appointment\",\"cooking\",\"warm\",\"paused\"]}"
	},
	{
		"code": "warm_time",
		"type": "Integer",
		"values": "{\"unit\":\"min\",\"min\":30,\"max\":1440,\"scale\":0,\"step\":1}"
	}
	]
},
"success": true,
"t": 1630599813188
}

Step 2: Send instructions to the device

You can debug the device functions by sending instructions in the instruction set to the device. For more information about APIs, see Send commands.

The following sample request is based on the device function properties that are obtained in the previous step, using switch as an example to send instructions.

Sample request

curl --request POST "https://openapi.tuyacn.com/v1.0/iot-03/devices/vdevo16********035/commands" --header "sign_method: HMAC-SHA256" --header "client_id: x37upht******bmmu0" --header "t: 1630599977335" --header "mode: cors" --header "Content-Type: application/json" --header "sign: DE7D1F28BB2C775*********0F4A45D09430A13D48C0E086" --header "access_token: 5eb******1371" --data "{"commands":"[{\"code\":\"switch\",\"value\":true}]"}"

Sample response

{
	"result": true,
	"success": true,
	"t": 1630599977705
}

Step 3: Query the latest status of the device

You can query the current status of the device with the following instructions. For more information about APIs, see Get the status of a single device.

After sending the switch instruction in Step 2, you can query the latest status of the device.

Sample request

curl --request GET "https://openapi.tuyacn.com/v1.0/devices/vdevo16********035/status" --header "sign_method: HMAC-SHA256" --header "client_id: x37******mmu0" --header "t: 1630600155872" --header "mode: cors" --header "Content-Type: application/json" --header "sign: BD000A8CC7F8E35************0851F75C64A202" --header "access_token: 5eb*********1371"

Sample response

{
"result": [
	{
	"code": "switch",
	"value": true
	},
	{
	"code": "start",
	"value": false
	},
	{
	"code": "appointment_time",
	"value": 0
	},
	{
	"code": "cook_time",
	"value": 0
	},
	{
	"code": "work_state",
	"value": "idle"
	},
	{
	"code": "warm_time",
	"value": 30
	}
],
"success": true,
"t": 1630600156146
}

List of category code

The category code field indicates the abbreviation of a specified product. The following table lists the products that match most instruction codes.

Category code Description
dj Light
xdd Ceiling light
fwd Ambiance light
dc String lights
dd Strip lights
gyd Motion sensor light
fsd Ceiling fan light
tyndj Solar light
tgq Dimmer
ykq Remote control
kg Switch
pc Power strip
cz Socket
cjkg Scene switch
ckqdkg Card switch
clkg Curtain switch
ckmkzq Garage door opener
tgkg Dimmer switch
rs Water heater
xfj Ventilation system
bx Refrigerator
yg Bathtub
xy Washing machine
kt Air conditioner
ktkzq Air conditioner controller
bgl Wall-hung boiler
sd Robot vacuum
qn Heater
kj Air purifier
lyj Drying rack
xxj Diffuser
cl Curtain
mc Door/window controller
wk Thermostat
yb Bathroom heater
ggq Irrigator
jsq Humidifier
cs Dehumidifier
fs Fan
js Water purifier
dr Electric blanket
cwtswsq Pet treat feeder
cwwqfsq Pet ball thrower
ntq HVAC
cwwsq Pet feeder
cwysj Pet fountain
sf Sofa
dbl Electric fireplace
tnq Smart milk kettle
msp Cat toilet
mjj Towel rack
sz Smart indoor garden
bh Smart kettle
mb Bread maker
kfj Coffee maker
nnq Bottle warmer
cn Milk dispenser
mzj Sous vide cooker
mg Rice cabinet
dcl Induction cooker
kqzg Air fryer
znfh Bento box
mal Alarm host
sp Smart camera
sgbj Siren alarm
zd Vibration sensor
mcs Contact sensor
rqbj Gas alarm
ywbj Smoke alarm
wsdcg Temperature and humidity sensor
sj Water leak detector
ylcg Pressure sensor
ldcg Luminance sensor
sos Emergency button
pm2.5 PM2.5 detector
pir Human motion sensor
cobj CO detector
co2bj CO2 detector
dgnbj Multi-functional alarm
jwbj Methane detector
hps Human presence sensor
ms Residential lock
bxx Safe box
gyms Business lock
jtmspro Residential lock pro
hotelms Hotel lock
ms_category Lock accessories
jtmsbh Smart lock (keep alive)
mk Access control
videolock Lock with camera
photolock Audio and video lock
amy Massage chair
liliao Physiotherapy product
ts Smart jump rope
tzc1 Body fat scale
sb Watch/band
zndb Smart electricity meter
znsb Smart water meter
dlq Circuit breaker
ds TV
tyy Projector
tracker Tracker
znyh Smart pill box