Last Updated on : 2024-06-20 04:16:03download
This topic describes how to perform integrated application development by using TuyaLink-based devices that are connected to the Tuya Developer Platform.
Cloud development is a one-stop development platform built by Tuya for smart solutions, providing fundamental products including smart device management, data analytics, rule engine, and more. It covers nine major industries such as real estate, industry, and energy. Furthermore, you can also develop with industry PaaS products including Smart Community, Smart Consumer Security, Smart Commercial Lighting, Smart Hotel, and Smart Apartment.
You can easily develop fundamental products with only a few lines of code, develop PaaS products on top of components, and select your desired industry products. Based on Tuya’s diversified functionality services, you can add industry products to various projects, perform resource management, and thus quickly implement a variety of industry SaaS. For more information, see Cloud Development.
A TuyaLink-based product refers to a product created by using the TuyaLink smart mode. For more information, see Device Connectivity.
The device binding code is a credential designed for TuyaLink-based devices that can be used to control device permissions. The bound object is granted permissions to control and get the device information. Two types of binding codes are provided to suit different scenarios.
Each device can be bound with only one asset object. After the binding is successful, the device will be in the bound state. For the specific method, see the following sections.
By default, a device only supports binding with a cloud project under the current account. If you need to support binding projects under other IoT accounts, go to the My Products page, click Manage Product in the Operation column of the target product, and then click Set Permissions for Device Binding.
Device capabilities refer to the northbound open API services provided by cloud development. Based on the device capabilities, application developers can implement data communication with devices, including device control and device message listener.
Capability type | Source | Definition |
---|---|---|
Standard capabilities | Tuya’s official definition | Standard capabilities indicate the capabilities to help achieve unified control across products and categories through Tuya’s standardized mapping and packaging. For example, on/off can be used as a standard capability. All devices with this capability can use the same set of parameters for unified control, bridging the hardware differences between products. |
Original capabilities | Auto-generated | The unconverted hardware product definitions on the device model. For example, the R value of a colored light (data point or property), camera initialization (action), and device power-down alarm (event). Please note that: To control a device based on original capabilities, you need to first understand the definitions of hardware product models such as data point (DP) model or things data model, before you can correctly send device commands or parse messages. |
Custom capabilities (coming soon) | Custom | The design and orchestration capabilities based on the device models, such as DP models or things data models. For example, a product has three properties: R , G , and B . For the convenience of operation, you can customize a capability control color and orchestrate the three properties into a method. You can request the method to control the color. Another example, a product can be used to measure weight and height. You can customize a capability get BMI . After you request the capability, the weight, height, and BMI are automatically returned. |
A project is a collection of resources on the Tuya Developer Platform. Resources assigned to each cloud project are isolated from those for other cloud projects. Custom and Smart Home projects are available. You can follow the prompts to create the desired project. For more information, see Create a project.
Cloud development allows you to manage the devices and assign the device permissions by asset IDs. This topic takes Community A-North Gate as an example. For more information, see Create an asset.
Before creation, subscribe to the IoT Core service first.
You can bind a TuyaLink-based device with an asset project by using the APIs or Device Management app. Before binding, make sure the product development has been completed and ready for release. The steps are as follows:
On the Devices tab of a cloud development project, place the pointer over Add Device, and select Add Device with Device Management App. Download and install the app.
On the Users tab of the project, add a user. This user account can be used to log in to the Device Management app.
On the Assets tab, click Authorized Users > Add Authorization to authorize the user.
Log in to the Device Management app, switch the asset to North Gate in the top left corner, tap Add, and then scan the binding QR code to add the device.
After the binding is successful, you can view the device in Assets > Devices of the project.
On the Assets tab of a project, click Add Device > Other to add a device.
You can enable the message service to timely receive messages about the device, such as device registration, data reporting, and status change.
Only the Message Queue service is available currently. The platform provides push notifications of message accumulation via SMS or email. For more information, see Quick Start of Message Queue.
Choose Cloud > Message Service, select a project, and then enable the message service.
For more information, see Get Push Messages by Pulsar (Java SDK).
On Tuya’s Value-Added Services (VAS) page, you can subscribe to the Device Northbound Service.
On the Service API tab of the project, click Go to Authorize, find the Device Northbound Service, and then authorize the project to use the service.
Click Debug in the Operation column of the device northbound service. The API Explorer will be opened for you to debug.
GET: /v1.0/iot-03/devices/{device_id}/capabilities-definition
The tag can be standard
and original
. For more information, see the API documents.
{
"result": {
"capabilities": [
{
"capability_code": "switch_led",
"methods": [
"get",
"post",
"event"
],
"name":"Light Switch",
"request": {
"description": "",
"name":"Switch",
"type": "boolean"
},
"response": {
"description": "",
"name":"Switch",
"type": "boolean"
},
"tags": [
"standard"
]
},
{
"capability_code": "bright_value",
"methods": [
"get",
"post",
"event"
],
"name":"Brightness value",
"request": {
"description": "",
"max": 1000,
"min": 10,
"name":"Brightness value",
"scale": 0,
"step": 1,
"type": "integer"
},
"response": {
"description": "",
"max": 1000,
"min": 10,
"name":"Brightness value",
"scale": 0,
"step": 1,
"type": "integer"
},
"tags": [
"standard"
]
},
],
"device_id": "vdevo159661074251***"
},
"success": true,
"t": 1644561248369
}
By analytics of the returned device list definition, the following important fields are extracted:
capability_code
: The capability code, which will be used when accessing the capability. For example, switch_led
in the above example.methods
: The methods that are used to access the capability. - get
: You can make API requests using the GET method. - post
: You can make API requests using the POST method. - event
: You can access the capability by subscribing to Pulsar messages.request
: The parameter description that is required when accessing the capability. As shown in the above example, the request parameter of switch_led
is of Boolean type. You should enter true
or false
when accessing the capability.response
: A description of the return result.The analytics of the capability list indicates that this device has a capability whose capability_code
is switch_led
, and its request parameter is of Boolean type.
You can set parameters in the API Explorer to implement this capability.
POST: /v1.0/iot-03/devices/{device_id}/capabilities-definition
It is similar to Execute device capability
, except that the access method is changed from POST to GET.
For more information, see Device Connectivity.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback