Scene Automation

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

API list

Request method API Description
GET /v1.1/homes/{home_id}/scenes Query the list of scenes in the home
GET /v1.0/scenes/default-pictures Query the list of default scene pictures
POST /v1.0/homes/{home_id}/scenes/{scene_id}/trigger Trigger a scene
POST /v1.0/homes/{home_id}/scenes Add a scene
DELETE /v1.0/homes/{home_id}/scenes/{scene_id} Delete a scene
PUT /v1.0/homes/{home_id}/scenes/{scene_id} Modify a scene
GET /v1.0/homes/{home_id}/scene/devices Query the list of devices that support the scene in the home
POST /v1.0/devices/{device_id}/scenes/{scene_id} Bind a scene
DELETE /v1.0/devices/{device_id}/scenes/{scene_id} Unbind a scene
GET /v1.0/devices/{device_id}/scenes Query the list of scenes bound to the device
POST /v1.0/homes/{home_id}/automations Add an automation
PUT /v1.0/homes/{home_id}/automations/{automation_id} Modify an automation
DELETE /v1.0/homes/{home_id}/automations/{automation_id} Delete an automation
GET /v1.1/homes/{home_id}/automations Query the automation list
GET /v1.0/homes/{home_id}/automations/{automation_id} Query an automation in the home
POST /v1.0/homes/{home_id}/automations
/{automation_id}/conditions/trigger
An external condition that triggers an automation in the home
GET /v1.0/homes/{home_id}/automation/devices Query the list of devices that support automation in the home
GET /v1.0/homes/automation/weather/conditions Query weather conditions supported by automation
GET /v1.0/homes/{home_id}/enable-linkage/codes Query the list of supported actions in the home
GET /v1.0/devices/{device_id}/enable-linkage/codes Get the linkage conditions supported by the device
PUT /v1.0/homes/{home_id}/automations
/{automation_id}/actions/enable
Enable an automation
PUT /v1.0/homes/{home_id}/automations
/{automation_id}/actions/disable
Disable an automation

Query the list of scenes in the home

API description

Query the list of scenes in the home.

API address

GET /v1.1/homes/{home_id}/scenes

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI Home ID Yes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Object The returned result.

Result

Parameter name Type Description
scene_id String Scene ID
name String Scene name
background String Background picture
enabled Boolean Whether to enable
status String The status. 1: valid, 2: invalid
actions List Action list

Actions

Parameter name Type Description
entity_id String Device ID.
executor_property JSON Action parameters.
action_executor String Action category. Currently, only dpIssue is available.

Request example

GET /v1.1/homes/5270711/scenes

Return example

{
    "success":true,
    "t":1541071460239,
    "result":[
        {
            "scene_id":"53IYSXI3gEn2w3Oc",
            "enabled": true,
            "status": "1",
            "name":"Enable the bulb light",
            "background":"https://images.tuyacn.com/smart/rule/cover/starry.png",
            "actions":[
                {
                    "entity_id":"0120090568c63a89cb34",
                    "executor_property":{
                        "work_mode":"scene_2"
                    },
                    "action_executor":"dpIssue"
                }
            ]
        },
        {
            "scene_id":"DKgx28KbdPfzEpvA",
            "name":"Morning",
            "background":"https://images.tuyacn.com/smart/rule/cover/sport2.png",
            "actions":[
                {
                    "entity_id":"012000715ccf7f4fb8b5",
                    "executor_property":{
                        "switch_led":true
                    },
                    "action_executor":"dpIssue"
                }
            ]
        }
    ]
}

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error
1106 Invalid permission

Query the list of default scene pictures

API description

Query the list of default scene pictures.

API address

GET /v1.0/scenes/default-pictures

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result List Return the list of scene picture addresses.

Request example

GET /v1.0/scenes/default-pictures

Return example

{
   "success":true,
   "t":1541071460239,
   "result":[
       "https://images.tuyacn.com/smart/rule/cover/starry.png",
       "https://images.tuyacn.com/smart/rule/cover/sport.png"
   ]
}

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error
1106 Invalid permission

Trigger a scene

API description

Trigger a scene.

API address

POST /v1.0/homes/{home_id}/scenes/{scene_id}/trigger

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI Home ID Yes
scene_id String URI Scene ID Yes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Object Whether the scene is triggered successfully. true is returned if the request succeeds.

Request example

POST /v1.0/homes/242****/scenes/53IYSXI3gEn2w3Oc/trigger

Return example

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

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error
1106 Invalid permission

Delete a scene

API description

Delete a scene in the home.

API address

DELETE /v1.0/homes/{home_id}/scenes/{scene_id}

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI Home ID Yes
scene_id String URI Scene ID Yes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Object Whether the scene is deleted successfully. true is returned if the request succeeds.

Request example

DELETE /v1.0/homes/242****/scenes/53IYSXI3gEn2w3Oc

Return example

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

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error
1106 Invalid permission

Add a scene

API description

Add a scene in a home.

API address

POST /v1.0/homes/{home_id}/scenes

Request parameter

Parameter name Type Parameter type Description Required
home_id String URI Home ID Yes
name String Body Scene name Yes
background String Body Background picture Yes
actions List Body Action list Yes

Description of Action

Parameter name Type Description Required
entity_id String Target ID Yes
executor_property JSON Action parameters No
action_executor String Action type Yes

Action instruction

  • Device action

    • entity_id:Device ID
    • action_executor:dpIssue
    • executor_property:Standard instructions
  • Delay action

    • entity_id:Device ID
    • action_executor:delay
    • executor_property:Delay parameters
  • Disable automation

    • entity_id:Automation ID
    • action_executor:ruleDisable
    • executor_property:NA
  • Enable automation

    • entity_id:Automation ID
    • action_executor:ruleEnable
    • executor_property:NA

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Object Scene ID.

Request example

POST /v1.0/homes/242****/scenes
{
    "name":"Add a scene for test",
    "background":"https://images.****.com/smart/rule/cover/sport.png",
    "actions":[
        {
             "executor_property":{
                  "hours":"0",
                  "minutes": "0",
                  "seconds": "5"
              },
             "action_executor":"delay"
        },
        {
            "executor_property":{
                "work_mode":"scene_2"
            },
            "action_executor":"dpIssue",
            "entity_id":"0120090568c63a8****"
        },
	{
                    "action_executor": "ruleDisable",
                    "entity_id": "AYJV2hh3eqm3****"
         },
	{
                    "action_executor": "ruleEnable",
                    "entity_id": "AYJV2hh3eqm3****"
         }
     ]
}

Return example

{
 "success": true,
 "t": 1541072348540,
 "result":"53IYSXI3gEn2w3Oc"
}

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error
1106 Invalid permission

Modify a scene

API description

Modify a scene in the home.

API address

PUT /v1.0/homes/{home_id}/scenes/{scene_id}

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI Home ID Yes
scene_id String Body Scene ID Yes
name String Body Scene name Yes
background String Body Background picture Yes
actions List Body Action list Yes

Description of devices in Action

Parameter name Type Description Required
entity_id String Device ID. Yes
executor_property JSON Action parameters. Yes
action_executor String Action category, for example, dpIssue. Yes

Description of delay in Action

Parameter name Type Description Required
executor_property JSON Action parameters. Yes
action_executor String Action category, for example, delay. Yes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Object true is returned if the request succeeds.

Request example

PUT /v1.0/homes/242****/scenes/53IYSXI3gEn2****    
{
    "name":"Add a scene for test",
    "background":"https://images.tuyacn.com/smart/rule/cover/sport.png",
    "actions":[
    {
                "executor_property":{
                    "hours":"0",
                    "minutes":"0",
                    "seconds":"5"
                },
                "action_executor":"delay"
            },
        {
            "executor_property":{
                "work_mode":"scene_2"
            },
            "action_executor":"dpIssue",
            "entity_id":"0120090568c63a89****"
        }
    ]
}

Return example

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

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error
1106 Invalid permission

Query the list of devices that support the scene in the home

API description

Query the list of devices that support the scene in the home.

API address

GET /v1.0/homes/{home_id}/scene/devices

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI The user’s home ID Yes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result List The returned result.

Result

Parameter name Type Description
device_id String Device ID
uuid String Universally unique identifier of the device
name String Name
home_id String Home ID
product_id String Product ID

Request example

GET /v1.0/homes/2422121/scene/devices

Return example of success

{
    "result":[
    	{
    		"id":"vedo123****",
    		"uuid":"asdfghnbvcx****",
        "name":"Test device",
    		"product_id":"r4567543****",
    		"home_id":"242****"
    	}
    ],
    "success":true,
    "t":1572936751228
}

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

Bind a scene

API description

The API mainly applies to scene switches. Scene switches have switch buttons, and each switch button has corresponding instructions. Through this API, the specified switch instruction can be bound to the scene, that is, the scene switch can be associated with the scene. After the binding is successful, the scene can be directly triggered through the instruction-sending API.

API address

POST /v1.0/devices/{device_id}/scenes/{scene_id}

Request parameter

Parameter name Type Parameter type Description Required
scene_id String URI Scene ID Yes
device_id String URI Device ID Yes
code String Body Code of standard instructions Yes
value String BODY Input parameter range of the instruction Yes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Long Room ID, room_id.

Result

Parameter name Type Description
Success Boolean Whether the execution succeeded or failed

Request example

POST /v1.0/devices/vdevo1575XXXX00013095/scenes/EqFkQ79XXXXXtjlkTm
{
	"code":"scene_1",
	"value":"scene"
}

Return example

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

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error
1106 Invalid permission

Unbind a scene

API description

The API mainly applies to scene switches. After a switch of the scene switch is bound to a specified scene, it can be unbound through this API.

API address

DELETE /v1.0/devices/{device_id}/scenes/{scene_id}

Request parameter

Parameter name Type Parameter type Description Required
device_id String URI Device ID Yes
scene_id String URI Scene ID Yes
code String BODY Code of standard instruction. The value corresponds to the scene switch button one by one. Yes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Long Room ID, room_id.

Result

Parameter name Type Description
Success Boolean Whether the execution succeeded or failed

Request example

DELETE /v1.0/devices/vdevo1575XXXX00013095/scenes/EqFkQ79XXXXXtjlkTm
{
	"code":"scene_1"
}

Return example

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

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error
1106 Invalid permission

Query the list of scenes bound to the device

API description

The API mainly applies to scene switches. Through the scene switch ID, query the list of the scenes associated with the device.

API address

GET /v1.0/devices/{device_id}/scenes

Request parameter

Parameter name Type Parameter type Description Required
device_id String URI Device ID Yes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
result Long Room ID, room_id.

Result

Parameter name Type Description
device_id Boolean Device ID
scenes Object List of bound scenes

Scenes

Parameter name Type Description
scene_id String Scene ID.
name String Scene name.
code String Binding instruction. The scene switch. One switch corresponds to one standard instruction.
value Object Input parameter range of the instruction.

Request example

GET /v1.0/devices/vdevo15758XXXX13095/scenes

Return example

{
    "result": {
        "device_id": "vdevo15758XXXX13095",
        "scenes": [
            {
                "code": "scene_2",
                "name": "Add scene G test—turn off the lights",
                "scene_id": "ilCZllmbXXXPOY36",
                "value": "scene"
            },
            {
                "code": "scene_1",
                "name": "Scene with bulb lights on",
                "scene_id": "EqFkQ79uXXXjlkTm",
                "value": "scene"
            }
        ]
    },
    "success": true,
    "t": 1576036860284
}

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error
1106 Invalid permission

Add an automation

API description

Add automation to the home.

API address

POST /v1.0/homes/{home_id}/automations

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI The user’s home ID. Yes
name String Body The name of the automation. Yes
background String Body Background picture. Yes
conditions List Body A list of conditions. Yes
actions List Body Action list. Yes
match_type Integer Body Match types:
  • 1: Trigger when any condition is met.
  • 2: Trigger when all conditions are met.
  • 3: Trigger by the custom condition. The logic operation parameter condition_rule must be set.
Yes
condition_rule String String Custom condition rules. When the match type is match_type=3, this parameter is required. The custom condition rules follow the AND/OR formula. Each automation condition uses its order_num as the identification code. No
preconditions List Body Precondition, with the highest priority. No

Note: For example, the order_num in condition_rule is 1, 2, and 3 in sequence. The service scene is as follows: the automation is triggered when conditions 1 and 2 are met at the same time, or condition 3 is met. Therefore, the expression is: 1&&2||3.

Conditions

Parameter name Type Description Required
entity_type Integer Condition type. Currently, the following types are available:
  • Device status condition: entity_type=1
  • External condition: entity_type = 15
  • Weather condition: entityType=3
  • Timing condition: entity_type=6
Yes
display JSON Display of conditions. Yes
order_num Integer Conditional sorting, starting from 1. Yes
entity_id String Action entities .
  • entity_type=1: The value is the device ID, which is required.
  • entity_type=15: The value is automatically generated by the system.
  • entit_type=3: The value is the ID of the corresponding city.
  • entity_type=6: The value is fixed to timer.
No

Display device status conditions

Parameter name Type Description Required
code String The statusCode of the device. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value String Code value. Yes

Display external conditions

Parameter name Type Description Required
code String Key of external conditions. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value Object Code value corresponding to the key of the external condition. Yes

Display weather conditions

Parameter name Type Description Required
code String The key corresponding to weather conditions, such as temperature temp. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value String Code value corresponding to the key of the weather condition. Yes

Display timing conditions

Parameter name Type Description Required
date String The trigger date in the format of yyyyMMdd, for example, 20191125. Yes
loops String A 7-digit number consisting of 0 and 1. 0 means not to execute, and 1 means to execute. The first digit represents Sunday, and the following digits represent Monday to Saturday in turn. For example, 0011000 means to execute every Tuesday and Wednesday. Yes
time String The trigger time in 24-hour clock, for example, 14:00. Yes
timezone_id String The ID of the time zone, for example, Asia/Shanghai. Yes

Description of preconditions

Predefined restrictions. Currently, it supports restrictions by time frame.

Parameter name Type Description Required
cond_type String Currently, it only supports restrictions by time frame, which is fixed as timeCheck. Yes
display JSON Display of conditions. Yes

Description of display in preconditions

Parameter name Type Description Required
start String The start time in 24-hour clock. The default value is a certain time of the day. For example, 10:00. Yes
end String The end time in 24-hour clock. For example, 22:00. Yes
loops String A 7-digit number consisting of 0 and 1. 0 means not to execute, and 1 means to execute. The first digit represents Sunday, and the following digits represent Monday to Saturday in turn. For example, 0011000 means to execute every Tuesday and Wednesday. Yes
timezone_id String The ID of the time zone, for example, Asia/Shanghai. Yes

Description of Action

Parameter name Type Description Required
entity_id String Target ID Yes
executor_property JSON Action parameters No
action_executor String Action type Yes

Action instruction

  • Device action

    • entity_id:Device ID
    • action_executor:dpIssue
    • executor_property:Standard instructions
  • Disable automation

    • entity_id:Automation ID
    • action_executor:ruleDisable
    • executor_property:NA
  • Enable automation

    • entity_id:Automation ID
    • action_executor:ruleEnable
    • executor_property:NA
  • Trigger scene

    • entity_id: scene ID
    • action_executor:ruleTrigger
    • executor_property:NA

Request example

POST /v1.0/homes/242****/automations
{
    "conditions":[
        {
            "display":{
                "code":"switch_1",
                "operator":"==",
                "value":true
            },
            "entity_id":"vdevo157259825422309",
            "entity_type":1,
            "order_num":1
        }
    ],
    "actions":[
    {
                "action_executor":"delay",
                "executor_property":{
    			  "hours": "0",
    			  "minutes": "0",
    			  "seconds": "5"
                }
            },
        {
            "action_executor":"dpIssue",
          	"entity_id":"vdevo157259825422309",
            "executor_property":{
			  "switch_1": true
            }
        }
    ],
    "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
    "match_type":1,
    "name":"Test the automation"
}

Example of preconditions

{
    "preconditions":[
        {
            "display":{
                "start":"10:00",
                "end":"12:00",
                "loops":"0010000",
                "timezone_id":"Asia/Shanghai"
            },
            "cond_type":"timeCheck"
        }
    ]
}

Example of device status conditions

{
    "conditions":[
        {
            "display":{
                "code":"switch_1",
                "operator":"==",
                "value":true
            },
            "entity_id":"vdevo157259825422309",
            "entity_type":1,
            "order_num":1
        }
    ]
}

Example of external conditions

{
    "conditions":[
        {
            "display":{
                "code":"test",
                "operator":"==",
                "value":"test"
            },
            "entity_type":15,
            "order_num":1
        }
    ]
}

Example of weather conditions

{
  "conditions":[
        {
            "display":{
                "code":"temp",
                "operator":"==",
                "value":"20"
            },
            "entity_id":"10",
            "entity_type":3,
            "order_num":1
        }
    ]
}

Example of timing conditions

{
  "conditions":[
        {
            "display":{
                "date":"20200301",
                "loops":"0000000",
                "time":"14:00",
                "timezone_id":"Asia/Shanghai"
            },
            "entity_id":"timer",
            "entity_type":6,
            "order_num":1
        }
    ]
}

Example of external actions

{
    "actions":[
        {
            "action_executor":"externalAction",
            "executor_property":{
              //Custom. It will be pushed through the message queue.
            }
        }
    ]
}

Code data type and operator mapping description

type operator
Boolean “==”
Integer “>”,“==”,“<”
Enum “==”

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result String Automation ID.

Return example of success

{
    "success": true,
    "t": 1541072348540,
    "result":"53IYSXI3gEn2w3Oc"
}

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

Modify an automation

API description

Modify the home automation configuration.

API address

PUT /v1.0/homes/{home_id}/automations/{automation_id}

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI The user’s home ID Yes
automation_id String URI Automation ID. Yes
name String Body The name of the automation. Yes
background String Body Background picture. Yes
conditions List Body A list of conditions. Yes
actions List Body Action list. Yes
match_type Integer Body Match types:
  • 1: Trigger when any condition is met.
  • 2: Trigger when all conditions are met.
  • 3: Trigger by the custom condition. The logic operation parameter condition_rule must be set.
Yes
condition_rule String String Custom condition rules. When the match type is match_type=3, this parameter is required. The custom condition rules follow the AND/OR formula. Each automation condition uses its order_num as the identification code. No
preconditions List Body Precondition, with the highest priority. No

Note: For example, the order_num in condition_rule is 1, 2, and 3 in sequence. The service scene is as follows: the automation is triggered when conditions 1 and 2 are met at the same time, or condition 3 is met. Therefore, the expression is: 1&&2||3.

Conditions

Parameter name Type Description Required
entity_type Integer Condition type. Currently, the following types are available:
  • Device status condition: entity_type=1
  • External condition: entity_type = 15
  • Weather condition: entity_type=3
  • Timing condition: entity_type=6
Yes
display JSON Display of conditions. Yes
order_num Integer Conditional sorting, starting from 1. Yes
entity_id String Action entities .
  • entity_type=1: The value is the device ID, which is required.
  • entity_type=15: The value is automatically generated by the system.
  • entit_type=3: The value is the ID of the corresponding city.
  • entity_type=6: The value is fixed to timer.
No

Display device status conditions

Parameter name Type Description Required
code String The statusCode of the device. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value String Code value. Yes

Display external conditions

Parameter name Type Description Required
code String Key of external conditions. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value Object Code value corresponding to the key of the external condition. Yes

Display weather conditions

Parameter name Type Description Required
code String The key corresponding to weather conditions, such as temperature temp. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value String Code value corresponding to the key of the weather condition. Yes

Display timing conditions

Parameter name Type Description Required
date String The trigger date in the format of yyyyMMdd, for example, 20191125. Yes
loops String A 7-digit number consisting of 0 and 1. 0 means not to execute, and 1 means to execute. The first digit represents Sunday, and the following digits represent Monday to Saturday in turn. For example, 0011000 means to execute every Tuesday and Wednesday. Yes
time String The trigger time in 24-hour clock, for example, 14:00. Yes
timezone_id String The ID of the time zone, for example, Asia/Shanghai. Yes

Description of preconditions

Predefined restrictions. Currently, it supports restrictions by time frame.

Parameter name Type Description Required
cond_type String Currently, it only supports restrictions by time frame, which is fixed as timeCheck. Yes
display JSON Display of conditions. Yes

Description of display in preconditions

Parameter name Type Description Required
start String The start time in 24-hour clock. The default value is a certain time of the day. For example, 10:00. Yes
end String The end time in 24-hour clock. For example, 22:00. Yes
loops String A 7-digit number consisting of 0 and 1. 0 means not to execute, and 1 means to execute. The first digit represents Sunday, and the following digits represent Monday to Saturday in turn. For example, 0011000 means to execute every Tuesday and Wednesday. Yes
timezone_id String The ID of the time zone, for example, Asia/Shanghai. Yes

Description of actions device

Parameter name Type Description Required
entity_id String Device ID. Yes
executor_property JSON Action parameters. Yes
action_executor String Action category, which is fixed to dpIssue. Yes

Description of external actions

Parameter name Type Description Required
executor_property JSON Custom external actions. Yes
action_executor String Action category, which is fixed to externalAction. Yes

Description of actions delay

Parameter name Type Description Required
executor_property JSON Action parameters. Yes
action_executor String Action category, which is fixed to delay. Yes

Request example

PUT /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc
{
            "actions":[
               {
                                   "action_executor":"delay",
                                   "executor_property":{
                                   	"hours":"0",
                                   	"minutes": "0",
                                   	"seconds": "5"
                                   }
                                
                               },
                {
                    "action_executor":"dpIssue",
                    "entity_id":"vdevo157259825422309",
                    "executor_property":{
                    	"switch_1":true
                    }
                 
                },
              	{
                    "action_executor":"externalAction",
                    "executor_property":{
                    	// User customized
                    }
                 
                }
            ],
          
            "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
            "conditions":[
               
               {
                    "display":{
                        "code":"switch_1",
                        "operator":"==",
                        "value":true
                    },
                    "entity_id":"vdevo157259825422309",
                    "entity_type":1,
                    "order_num":1
                },
                {
                    "display":{
                        "code":"mode",
                        "operator":"==",
                        "value":1
                    },
                    "entity_type":15,
                    "order_num":2
                }
            ],
            "match_type":1,
            "name":"Test the automation"
        }

Example of preconditions

{
    "preconditions":[
        {
            "display":{
                "start":"10:00",
                "end":"12:00",
                "loops":"0000000",
                "timezone_id":"Asia/Shanghai"
            },
            "cond_type":"timeCheck"
        }
    ]
}

Example of device status conditions

{
    "conditions":[
        {
            "display":{
                "code":"switch_1",
                "operator":"==",
                "value":true
            },
            "entity_id":"vdevo157259825422309",
            "entity_type":1,
            "order_num":1
        }
    ]
}

Example of external conditions

{
    "conditions":[
        {
            "display":{
                "code":"test",
                "operator":"==",
                "value":"test"
            },
            "entity_type":15,
            "order_num":1
        }
    ]
}

Example of weather conditions

{
  "conditions":[
        {
            "display":{
                "code":"temp",
                "operator":"==",
                "value":"20"
            },
            "entity_id":"10",
            "entity_type":3,
            "order_num":1
        }
    ]
}

Example of timing conditions

{
  "conditions":[
        {
            "display":{
                "date":"20200301",
                "loops":"0000000",
                "time":"14:00",
                "timezone_id":"Asia/Shanghai"
            },
            "entity_id":"timer",
            "entity_type":6,
            "order_num":1
        }
    ]
}

Example of external actions

{
    "actions":[
        {
            "action_executor":"externalAction",
            "executor_property":{
              //Custom. It will be pushed through the message queue. 
            }
        }
    ]
}

Example of delay actions

{
   "action_executor":"delay",
   "executor_property":{
    "hours":"0",
    "minutes": "0",
    "seconds": "5"
   }

}

Code data type and operator mapping description

type operator
Boolean “==”
Integer “>”,“==”,“<”
Enum “==”

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result String true is returned if the request succeeds.

Return example of success

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

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

Delete an automation

API description

Delete the home automation configuration.

API address

DELETE /v1.0/homes/{home_id}/automations/{automation_id}

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI The user’s home ID Yes
automation_id String URI Automation ID Yes

Request example

DELETE /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result String Whether the automation is deleted successfully. true is returned if the request succeeds.

Return example of success

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

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

Query the automation list

API description

Query the automation list.

API address

GET /v1.1/homes/{home_id}/automations

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI The user’s home ID Yes

Request example

GET /v1.1/homes/242****/automations

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result List The returned result.

Result

Parameter name Type Description
automation_id String Automation ID.
name String The name of the automation.
enabled Boolean Enable status.
status String The status. 1: valid, 2: invalid
background String Background picture.
conditions List A list of conditions.
preconditions List Preconditions.
actions List Action list.
match_type Integer Match types:
  • 1: Trigger when any condition is met.
  • 2: Trigger when all conditions are met.
  • 3: Trigger by the custom condition. The logic operation parameter condition_rule must be set.
condition_rule String Custom condition rules. When the match type is match_type=3, this parameter is required. The custom condition rules follow the AND/OR formula. Each automation condition uses its order_num as the identification code.

Conditions

Parameter name Type Description Required
entity_type Integer Condition type. Currently, the following types are available:
  • Device status condition: entity_type=1
  • External condition: entity_type = 15
  • Weather condition: entity_type=3
  • Timing condition: entity_type=6
Yes
display JSON Display of conditions. Yes
order_num Integer Conditional sorting, starting from 1. Yes
entity_id String Action entities .
  • entity_type=1: The value is the device ID, which is required.
  • entity_type=15: The value is automatically generated by the system.
  • entit_type=3: The value is the ID of the corresponding city.
  • entity_type=6: The value is fixed to timer.
No

Display device status conditions

Parameter name Type Description Required
code String The statusCode of the device. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value String Code value. Yes

Display external conditions

Parameter name Type Description Required
code String Key of external conditions. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value Object Code value corresponding to the key of the external condition. Yes

Display weather conditions

Parameter name Type Description Required
code String The key corresponding to weather conditions, such as temperature temp. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value String Code value corresponding to the key of the weather condition. Yes

Display timing conditions

Parameter name Type Description Required
date String The trigger date in the format of yyyyMMdd, for example, 20191125. Yes
loops String A 7-digit number consisting of 0 and 1. 0 means not to execute, and 1 means to execute. The first digit represents Sunday, and the following digits represent Monday to Saturday in turn. For example, 0011000 means to execute every Tuesday and Wednesday. Yes
time String The trigger time in 24-hour clock, for example, 14:00. Yes
timezone_id String The ID of the time zone, for example, Asia/Shanghai. Yes

Description of preconditions

Predefined restrictions. Currently, it supports restrictions by time frame.

Parameter name Type Description Required
cond_type String Currently, it only supports restrictions by time frame, which is fixed as timeCheck. Yes
display JSON Display of conditions. Yes

Description of display in preconditions

Parameter name Type Description Required
start String The start time in 24-hour clock. The default value is a certain time of the day. For example, 10:00. Yes
end String The end time in 24-hour clock. For example, 22:00. Yes
loops String A 7-digit number consisting of 0 and 1. 0 means not to execute, and 1 means to execute. The first digit represents Sunday, and the following digits represent Monday to Saturday in turn. For example, 0011000 means to execute every Tuesday and Wednesday. Yes
timezone_id String The ID of the time zone, for example, Asia/Shanghai. Yes

Description of actions device

Parameter name Type Description Required
entity_id String Device ID. Yes
executor_property JSON Action parameters. Yes
action_executor String Action category, which is fixed to dpIssue. Yes

Description of external actions

Parameter name Type Description Required
executor_property JSON Custom external actions. Yes
action_executor String Action category, which is fixed to externalAction. Yes

Code data type and operator mapping description

type operator
Boolean “==”
Integer “>”,“==”,“<”
Enum “==”

Return example of success

{
    "result":[
        {
            "actions":[
                {
                   "action_executor":"delay",
                   "executor_property":{
                    "hours":"0",
                    "minutes": "0",
                    "seconds": "5"
                   }
                
                },
                {
                    "action_executor":"dpIssue",
                    "entity_id":"vdevo157259825422309",
                    "executor_property":{
                        "switch_1":true
                    }
                },
              	{
                    "action_executor":"externalAction",
                    "executor_property":{
                    	// User customized
                    }
                 
                }
            ],
            "automation_id":"p2aWOkEOe2RzATHL",
            "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
            "conditions":[
                {
                    "display":{
                        "code":"switch_1",
                        "operator":"==",
                        "value":true
                    },
                    "entity_id":"vdevo157259825422309",
                    "entity_type":1,
                    "order_num":1
                }
            ],
            "enabled": true,
            "status": "1",
            "match_type":1,
            "name":"Test the automation"
        },
        {
            "automation_id":"L07BQVabdqwFPT9K",
            "background":"https://images.tuyacn.com/smart/rule/cover/house6.png",
            "conditions":[
                {
                    "display":{
                        "code":"battery_percentage",
                        "operator":"<",
                        "value":255
                    },
                    "entity_id":"vdevo156958314001174",
                    "entity_type":1,
                    "order_num":1
                },
                {
                    "display":{
                        "code":"mode",
                        "operator":"==",
                        "value":1
                    },
                    "entity_id":"weqszcaokqlmlkmlcanqklwokljlaf",
                    "entity_type":15,
                    "order_num":2
                }
            ],
            "enabled": true,
            "status": "1",
            "match_type":1,
            "name":"Automation test 1"
        }
    ],
    "success":true,
    "t":1572936751228
}

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

Query an automation

API description

Query a single automation scene in the home.

API address

GET /v1.0/homes/{home_id}/automations/{automation_id}

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI The user’s home ID Yes
automation_id String URI Automation scene ID Yes

Request example

GET /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result Object The returned result.

Result

Parameter name Type Description
automation_id String Automation scene ID.
name String Automation scene name.
enabled Boolean Enable status.
background String Background picture.
conditions List A list of conditions.
preconditions List Preconditions.
actions List Action list.
match_type Integer Match types:
  • 1: Trigger when any condition is met.
  • 2: Trigger when all conditions are met.
  • 3: Trigger by the custom condition. The logic operation parameter condition_rule must be set.
condition_rule String Custom condition rules. When the match type is match_type=3, this parameter is required. The custom condition rules follow the AND/OR formula. Each automation condition uses its order_num as the identification code.

Conditions

Parameter name Type Description Required
entity_type Integer Condition type. Currently, the following types are available:
  • Device status condition: entity_type=1
  • External condition: entity_type = 15
  • Weather condition: entity_type=3
  • Timing condition: entity_type=6
Yes
display JSON Display of conditions. Yes
order_num Integer Conditional sorting, starting from 1. Yes
entity_id String Action entities .
  • entity_type=1: The value is the device ID, which is required.
  • entity_type=15: The value is automatically generated by the system.
  • entit_type=3: The value is the ID of the corresponding city.
  • entity_type=6: The value is fixed to timer.
No

Display device status conditions

Parameter name Type Description Required
code String The statusCode of the device. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value String Code value. Yes

Display external conditions

Parameter name Type Description Required
code String Key of external conditions. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value Object Code value corresponding to the key of the external condition. Yes

Display weather conditions

Parameter name Type Description Required
code String The key corresponding to weather conditions, such as temperature temp. Yes
operator String Operators. See Code data type and operator mapping description. Yes
value String Code value corresponding to the key of the weather condition. Yes

Display timing conditions

Parameter name Type Description Required
date String The trigger date in the format of yyyyMMdd, for example, 20191125. Yes
loops String A 7-digit number consisting of 0 and 1. 0 means not to execute, and 1 means to execute. The first digit represents Sunday, and the following digits represent Monday to Saturday in turn. For example, 0011000 means to execute every Tuesday and Wednesday. Yes
time String The trigger time in 24-hour clock, for example, 14:00. Yes
timezone_id String The ID of the time zone, for example, Asia/Shanghai. Yes

Description of preconditions

Predefined restrictions. Currently, it supports restrictions by time frame.

Parameter name Type Description Required
cond_type String Currently, it only supports restrictions by time frame, which is fixed as timeCheck. Yes
display JSON Display of conditions. Yes

Description of display in preconditions

Parameter name Type Description Required
start String The start time in 24-hour clock. The default value is a certain time of the day. For example, 10:00. Yes
end String The end time in 24-hour clock. For example, 22:00. Yes
loops String A 7-digit number consisting of 0 and 1. 0 means not to execute, and 1 means to execute. The first digit represents Sunday, and the following digits represent Monday to Saturday in turn. For example, 0011000 means to execute every Tuesday and Wednesday. Yes
timezone_id String The ID of the time zone, for example, Asia/Shanghai. Yes

Description of actions device

Parameter name Type Description Required
entity_id String Device ID. Yes
executor_property JSON Action parameters. Yes
action_executor String Action category, which is fixed to dpIssue. Yes

Description of external actions

Parameter name Type Description Required
executor_property JSON Custom external actions. Yes
action_executor String Action category, which is fixed to externalAction. Yes

Code data type and operator mapping description

type operator
Boolean “==”
Integer “>”,“==”,“<”
Enum “==”

Return example of success

{
    "result":[{
            "actions":[
                {
                   "action_executor":"delay",
                   "executor_property":{
                    "hours":"0",
                    "minutes": "0",
                    "seconds": "5"
                   }
                
                },
                {
                    "action_executor":"dpIssue",
                    "entity_id":"vdevo157259825422309",
                    "executor_property":{
                        "switch_1":true
                    }
                },
                {
                    "action_executor":"externalAction",
                    "executor_property":{
                        // User customized
                    }
                 
                }
            ],
            "automation_id":"p2aWOkEOe2RzATHL",
            "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
            "conditions":[
                {
                    "display":{
                        "code":"switch_1",
                        "operator":"==",
                        "value":true
                    },
                    "entity_id":"vdevo157259825422309",
                    "entity_type":1,
                    "order_num":1
                }
            ],
            "enabled": true,
            "match_type":1,
            "name":"Test the automation"
        },
        {
            "automation_id":"L07BQVabdqwFPT9K",
            "background":"https://images.tuyacn.com/smart/rule/cover/house6.png",
            "conditions":[
                {
                    "display":{
                        "code":"battery_percentage",
                        "operator":"<",
                        "value":255
                    },
                    "entity_id":"vdevo156958314001174",
                    "entity_type":1,
                    "order_num":1
                },
                {
                    "display":{
                        "code":"mode",
                        "operator":"==",
                        "value":1
                    },
                    "entity_id":"weqszcaokqlmlkmlcanqklwokljlaf",
                    "entity_type":15,
                    "order_num":2
                }
            ],
            "enabled": true,
            "match_type":1,
            "name":"Automation test 1"
        },
    "success":true,
    "t":1572936751228
}

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

External condition that triggers automation

API description

An external condition that triggers an automation scene in the home.

API address

POST /v1.0/homes/{home_id}/automations/{automation_id}/conditions/trigger

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI The user’s home ID Yes
automation_id String URI Automation scene ID Yes
conditions List Body A list of conditions Yes

Conditions

Parameter name Type Description Required
entity_id String ID of an external condition Yes
display JSON Condition Yes

Display

Parameter name Type Description Required
code String The statusCode of the device Yes
value String Code value Yes

Request example

POST /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc/conditions/trigger
[{
	"entity_id":"c9a5a524-d973-4b59-9390-0dcda0f172ec",
	"display":{
		"code":"test",
		"value":"test"
	}
}]

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result String Whether the scene is triggered successfully. true is returned if the request succeeds.

Return example of success

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

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

Query the list of devices that support automation scenes

API description

Query the list of devices that support automation scenes in the home.

API address

GET /v1.0/homes/{home_id}/automation/devices

Request parameter

Parameter name Type Parameter type Description Required
home_id Long URI The user’s home ID Yes
type String URL Supported types:
  • condition: condition type
  • action: action type
No

Note: If the type parameter is not output, all devices that support automation scenes will be returned.

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result List The returned result.

Result

Parameter name Type Description
device_id String Device ID
uuid String Universally unique identifier of the device
name String Name
home_id String Home ID
product_id String Product ID

Request example

GET /v1.0/homes/242****/automation/devices?type=condition

Return example of success

{
    "result":[
    	{
    		"id":"vedo123****",
    		"uuid":"asdfghnbvcx****",
        "name":"Test device",
    		"product_id":"r4567543****",
    		"home_id":"242****"
    	}
    ],
    "success":true,
    "t":1572936751228
}

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

Query weather conditions supported by automation scenes

API description

Query weather conditions supported by automation

API address

GET /v1.0/homes/automation/weather/conditions

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result List The returned result.

Result

Parameter name Type Description
category String Category
category_name String Category name
operators String Operator
property JSON Category property

Request example

GET /v1.0/homes/automation/weather/conditions

Return example of success

{
    "result":[
    		{
    			"category":"temp",
    			"category_name":"Temperature",
    			"operators":"[\"<\",\"==\",\">\"]",
    			"property":{
                    "unit": "℃",
                    "min": -40,
                    "max": 40,
                    "step": 1,
                    "type": "value"
                },
    		}
    ],
    "success":true,
    "t":1572936751228
}

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

Get the linkage conditions supported by the home

API description

Get linkage conditions or standard data points for performing actions based on the home ID.

API address

GET /v1.0/homes/{home_id}/enable-linkage/codes

Request parameter

Parameter name Type Parameter type Description Required
home_id String URI Home ID Yes

Request example

GET /v1.0/homes/5232322/enable-linkage/codes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result List The returned result.

Result

Parameter name Type Description
device_id String Automation device ID.
functions List Operation performed.
status List The condition triggering operation.

Functions

Parameter name Type Description
code String Code of standard instructions sent.
name String Code name.
type String Types of the sent data. Currently, the following three types are available:
  • Boolean
  • Integer
  • Enum
values JSON Code value range.

Status

Parameter name Type Description
code String Code of standard statuses reported.
name String Code name.
type String Types of the reported data. Currently, the following three types are available:
  • Boolean
  • Integer
  • Enum
values JSON Code value range.

Return example of success

{
    "success": true,
    "t": 1541072348540,
    "result": [
                {
                  "device_id": "0120090568c63a89cb34",
                  "functions": [
                      {
                          "name": "Brightness",
                          "code": "bright_value",
                          "type": "Integer",
                          "values": {
                                        "max":255,
                                        "min":25,
                                        "scale":0,
                                        "step":1,
                                        "type":"value",
                                        "unit":""
                                    }
                      },
                      {
                        "name": "Switch",
                        "code": "switch_led",
                        "type": "Boolean"
                    }
                  ],
                  "status": [
                      {
                          "name": "Mode",
                          "code": "work_mode",
                          "type": "Enum",
                          "values":  {
                                        "range": [
                                                    "white",
                                                    "colour",
                                                    "scene",
                                                    "scene_1",
                                                    "scene_2",
                                                    "scene_3",
                                                    "scene_4"
                                                ],
                                         "type": "Enum"
                                    }
                      }
                  ]
                }
            ]
}

Return example of failure

{ "success": false, "code": 1100, "msg": "param is empty", "t": 1540954683193 }

Get the linkage conditions supported by the device

API description

Get linkage conditions or standard data points for performing actions based on the home ID.

API address

GET /v1.0/devices/{device_id}/enable-linkage/codes

Request parameter

Parameter name Type Parameter type Description Required
device_id String URI Device ID Yes

Request example

GET /v1.0/devices/0120090568c63a89cb34/enable-linkage/codes

Return parameter

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result Object The returned result.

Result

Parameter name Type Description
device_id String Device ID.
functions List Standard instructions for performing actions.
status List The standard status to trigger actions.

Functions

Parameter name Type Description
code String Code of standard instructions sent.
name String Code name.
type String Types of the sent data. Currently, the following three types are available:
  • Boolean
  • Integer
  • Enum
values JSON Code value range.

Status

Parameter name Type Description
code String Code of standard statuses reported.
name String Code name.
type String Types of the reported data. Currently, the following three types are available:
  • Boolean
  • Integer
  • Enum
values JSON Code value range.

Return example of success

{
    "success": true,
    "t": 1541072348540,
    "result": {
                  "device_id": "0120090568c63a89cb34",
                  "functions": [
                      {
                          "name": "Brightness",
                          "code": "bright_value",
                          "type": "Integer",
                          "values": {
                                        "max":255,
                                        "min":25,
                                        "scale":0,
                                        "step":1,
                                        "type":"Integer",
                                        "unit":""
                                    }
                      },
                      {
                        "name": "Switch",
                        "code": "switch_led",
                        "type": "Boolean",
                        "values": {
                                    "type": "Boolean"
                                  }
                    }
                  ],
                  "status": [
                      {
                          "name": "Mode",
                          "code": "work_mode",
                          "type": "Enum",
                          "values":  {
                                        "range": [
                                                    "white",
                                                    "colour",
                                                    "scene",
                                                    "scene_1",
                                                    "scene_2",
                                                    "scene_3",
                                                    "scene_4"
                                                ],
                                         "type": "Enum"
                                    }
                      }
                  ]
            }
}

Return example of failure

{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}

Enable an automation

API description

Enable automation scenes.

API address

PUT /v1.0/homes/{home_id}/automations/{automation_id}/actions/enable

Request parameter

Parameter name Type Parameter type Description Required
home_id Long Home ID URI Yes
automation_id String Automation scene ID URI Yes

Return parameter:

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result Boolean The returned result.

Request example

PUT /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc/actions/enable

Return example

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

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error

Disable an automation

API description

Disable automation scenes.

API address

PUT /v1.0/homes/{home_id}/automations/{automation_id}/actions/disable

Request parameter

Parameter name Type Parameter type Description Required
home_id Long Home ID URI Yes
automation_id String Automation scene ID URI Yes

Return parameter:

Parameter name Type Description
code Integer Response code. See Error Code.
success Boolean Whether the request succeeded or not.
  • true: succeeded
  • false: failed
msg String The message returned if the request fails. It is empty on success.
t Long Return a 13-bit timestamp.
result Boolean The returned result.

Request example

PUT /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc/actions/disable

Return example

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

Error code

The following are common service exceptions for this API. For more exception errors, see Error Code.

Error code Description
500 System error