Project Management

Last Updated on : 2023-11-14 02:28:53download

This topic describes how to create a commercial lighting project. This is the first step to connect to Tuya commercial lighting SaaS. This allows you to manage the required scenes based on projects.

API list

Request method API endpoint Description
POST /v1.0/illumination/construction/project Create a project
PUT /v1.0/illumination/construction/project Edit a project
DELETE /v1.0/illumination/construction/project/{projectId} Delete a project
GET /v1.0/illumination/construction/project/{projectId} Get information about a project
GET /v1.0/illumination/construction/projects Get the list of projects
GET /v1.0/iot-02/projects/{project_id}/devices/count Query device statistics of the project

Create a project

API description

Create a project.

API endpoint

POST /v1.0/illumination/construction/project

Request parameters

Parameter name Type Parameter type Description Required
name string body The project name. Yes
leaderMobile string body The project leader’s phone number. Yes
leaderName string body The project leader’s name. Yes
address string body The location of the project. Yes
detail string body The specific address of the project, rather than geographic coordinates. No
longitude double body The longitude of the project address. Yes
latitude double body The latitude of the project address. Yes
projectType Integer body The project type. Valid values:
  • 0: a project suitable for indoor scenes
  • 1: a project suitable for outdoor scenes
  • 2: a project suitable for parking lot scenes
No

Response parameters

Parameter name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  "projectId": "string // The project ID",
  "ownerId": "string // The home ID"
}

Sample request

{
  "leaderMobile": "The project leader's phone number",
  "address": "The project address",
  "leaderName": "The project leader's name",
  "latitude": "The latitude of the project address",
  "name": "The project name",
  "detail": "The specific address of the project, rather than geographic coordinates",
  "longitude": "The longitude of the project address"
}

Sample response

{
  "ownerId": "The home ID",
  "projectId": "The project ID"
}

Edit a project

API description

Edit the specified project.

API endpoint

PUT /v1.0/illumination/construction/project

Request parameters

Parameter name Type Parameter type Description Required
projectId string body The project ID. Yes
name string body The project name. No
leaderMobile string body The project leader’s phone number. No
leaderName string body The project leader’s name. No
address string body The location of the project. No
detail string body The specific address of the project, rather than geographic coordinates. No
longitude double body The longitude of the project address. No
latitude double body The latitude of the project address. No

Response parameters

Parameter name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  "projectId": "string // The project ID"
}

Sample request

{
  "leaderMobile": "The project leader's phone number",
  "address": "The project address",
  "leaderName": "The project leader's name",
  "latitude": "The latitude of the project address",
  "name": "The project name",
  "detail": "The specific address of the project, rather than geographic coordinates",
  "projectId": "The project ID",
  "longitude": "The longitude of the project address"
}

Sample response

{
  "projectId": "The project ID"
}

Delete a project

API description

Delete the specified project.

API endpoint

DELETE /v1.0/illumination/construction/project/{projectId}

Request parameters

Parameter name Type Parameter type Description Required
projectId string url The project ID. Yes

Response parameters

Parameter name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  "success": "boolean"
}

Sample request

{
  "projectId": "The project ID"
}

Sample response

{
  "success": "Indicate whether the request is successful"
}

Get information about a project

API description

Get the information about the specified project.

API endpoint

GET /v1.0/illumination/construction/project/{projectId}

Request parameters

Parameter name Type Parameter type Description Required
projectId string url The project ID. Yes

Response parameters

Parameter name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  "projectId": "string // The project ID",
  "ownerId": "string // The home ID",
  "name": "string // The project name",
  "leaderMobile": "string // The project leader's phone number",
  "leaderName": "string // The project leader's name",
  "address": "string // The project address",
  "detail": "string // The specific address of the project",
  "longitude": "double // The longitude of the project address",
  "latitude": "double // The latitude of the project address",
  "timeZoneId": "string // The time zone ID",
  "timeZone": "string // The time zone of the project address",
  "zoneId": "string // The time zone ID of the project address",
  "source": "int // The source of the project",
  "locationId": "long // The home location ID",
  "gmtCreate": "long // The time when the project was created",
  "controlMode": "int // The control mode",
  "success": "boolean",
  "namespace": "string"
}

Sample request

{
  "projectId": "string // The project ID"
}

Sample response

{
  "projectId": "The project ID",
  "ownerId": "The home ID",
  "name": "The project name",
  "leaderMobile": "The project leader's phone number",
  "leaderName": "The project leader's name",
  "address": "The project address",
  "detail": "The specific address of the project",
  "longitude": "The longitude of the project address",
  "latitude": "The latitude of the project address",
  "timeZoneId": "The time zone ID",
  "timeZone": "The time zone of the project address",
  "zoneId": "The time zone ID of the project address",
  "source": "The source of the project",
  "locationId": "The home location ID",
  "gmtCreate": "The creation time",
  "controlMode": "The control mode",
  "success": "boolean",
  "namespace": "string"
}

Get the list of projects

API description

Get the list of projects.

API endpoint

GET /v1.0/illumination/construction/projects

Request parameters

Parameter name Type Parameter type Description Required
page int body The page number starting from 1. No
pageSize int body The number of entries per page. Maximum value: 10,000. No
keyword string body The keywords of search. No

Response parameters

Parameter name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  "total": "int",
  "list": [
    {
      "projectId": "string // The project ID",
      "ownerId": "string // The home ID",
      "name": "string // The project name",
      "leaderMobile": "string // The project leader's phone number",
      "leaderName": "string // The project leader's name",
      "address": "string // The project address",
      "detail": "string // The specific address of the project",
      "longitude": "double // The longitude of the project address",
      "latitude": "double // The latitude of the project address",
      "timeZoneId": "string // The time zone ID",
      "timeZone": "string // The time zone of the project address",
      "zoneId": "string // The time zone ID of the project address",
      "source": "int // The source of the project",
      "locationId": "long // The home location ID",
      "gmtCreate": "long // The time when the project was created",
      "controlMode": "int // The control mode",
      "success": "boolean",
      "namespace": "string"
    }
  ]
}

Sample request

{
  "pageSize": "The number of entries per page",
  "page": "The page number"
}

Sample response

{
  "total": "int",
  "list": [
    {
      "projectId": "The project ID",
      "ownerId": "The home ID",
      "name": "The project name",
      "leaderMobile": "The project leader's phone number",
      "leaderName": "The project leader's name",
      "address": "The project address",
      "detail": "The specific address of the project",
      "longitude": "The longitude of the project address",
      "latitude": "The latitude of the project address",
      "timeZoneId": "The time zone ID",
      "timeZone": "The time zone of the project address",
      "zoneId": "The time zone ID of the project address",
      "source": "The source of the project",
      "locationId": "The home location ID",
      "gmtCreate": "The creation time",
      "controlMode": "The control mode",
      "success": "boolean",
      "namespace": "string"
    }
  ]
}

Query device statistics of the project

API description

Query the device statistics information about the specified project, including the total number of devices, the number of online devices, offline devices, and devices that send an alert.

API endpoint

GET /v1.0/iot-02/projects/{project_id}/devices/count

Request parameters

Parameter name Type Parameter type Description Required
project_id string url The project ID. Yes

Response parameters

Parameter name Type Description
code Integer The response code. For more information, see the error code section. It is empty if the request is successful.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
msg String The message that is returned if the request failed. The response is empty if the request is successful.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  "projectId": "String // The project ID",
  "deviceCount": "int // The number of devices",
  "onlineDeviceCount": "int // The number of online devices",
  "offlineDeviceCount": "int // The number of offline devices",
  "alarmDeviceCount": "int // The number of devices that send an alert"
}

Sample response

{
  "projectId": "The project ID",
  "deviceCount": "The number of devices",
  "onlineDeviceCount": "The number of online devices",
  "offlineDeviceCount": "The number of offline devices",
  "alarmDeviceCount": "The number of devices that send an alert"
}

Error codes

The following table lists the error codes that might be returned when you make the API request. For more error codes, see Global Error Codes.

Error codes Description
500 A system error has occurred while processing your request.