更新时间:2023-06-15 05:09:20
请求方式  | 
API | 描述 | 
|---|---|---|
| GET | /v1.1/homes/{home_id}/scenes | 查询家庭下的场景列表 | 
| GET | /v1.0/scenes/default-pictures | 查询默认场景图片列表 | 
| POST | /v1.0/homes/{home_id}/scenes/{scene_id}/trigger | 触发场景 | 
| POST | /v1.0/homes/{home_id}/scenes | 添加场景 | 
| DELETE | /v1.0/homes/{home_id}/scenes/{scene_id} | 删除场景 | 
| PUT | /v1.0/homes/{home_id}/scenes/{scene_id} | 修改场景 | 
| GET | /v1.0/homes/{home_id}/scene/devices | 查询家庭下支持场景的设备列表 | 
| GET | /v1.0/devices/{device_id}/enable-linkage/codes | 获取设备支持的联动条件 | 
| POST | /v1.0/devices/{device_id}/scenes/{scene_id} | 场景绑定 | 
| DELETE | /v1.0/devices/{device_id}/scenes/{scene_id} | 场景解绑 | 
| GET | /v1.0/devices/{device_id}/scenes | 查询设备已绑定的场景列表 | 
| POST | /v1.0/homes/{home_id}/automations | 添加自动化 | 
| PUT | /v1.0/homes/{home_id}/automations /{automation_id}  | 
修改自动化 | 
| DELETE | /v1.0/homes/{home_id}/automations /{automation_id}  | 
删除自动化 | 
| GET | /v1.1/homes/{home_id}/automations | 查询自动化列表 | 
| GET | /v1.0/homes/{home_id}/automations /{automation_id}  | 
查询家庭下的某个自动化 | 
| POST | /v1.0/homes/{home_id}/automations /{automation_id}/conditions/trigger  | 
触发家庭下某个自动化的外部条件 | 
| GET | /v1.0/homes/{home_id}/automation /devices  | 
查询家庭下支持自动化的设备列表 | 
| GET | /v1.0/homes/automation/weather/conditions | 查询自动化支持的天气条件 | 
| GET | /v1.0/homes/{home_id}/enable-linkage/codes | 查询家庭下支持的动作列表 | 
| PUT | /v1.0/homes/{home_id}/automations /{automation_id}/actions/enable  | 
启用自动化 | 
| PUT | /v1.0/homes/{home_id}/automations /{automation_id}/actions/disable  | 
停用自动化 | 
查询家庭下的场景列表。
GET /v1.1/homes/{home_id}/scenes
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 家庭 ID | 是 | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | Object | 返回结果。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| scene_id | String | 场景 ID | 
| name | String | 场景名称 | 
| background | String | 背景图片 | 
| enabled | Boolean | 是否启用 | 
| status | String | 状态。1:正常,2:失效 | 
| actions | List | 动作列表 | 
Actions
| 参数名 | 类型 | 说明 | 
|---|---|---|
| entity_id | String | 设备 ID。 | 
| executor_property | JSON | 执行动作参数。 | 
| action_executor | String | 执⾏动作类别,当前仅支持 dpIssue。 | 
GET /v1.1/homes/5270711/scenes
{
    "success":true,
    "t":1541071460239,
    "result":[
        {
            "scene_id":"53IYSXI3gEn2w***",
            "enabled": true,
            "status":"1",
            "name":"开启球泡灯",
            "background":"https://images.tuyacn.com/smart/rule/cover/starry.png",
            "actions":[
                {
                    "entity_id":"0120090568c63a89****",
                    "executor_property":{
                        "work_mode":"scene_2"
                    },
                    "action_executor":"dpIssue"
                }
            ]
        },
        {
            "scene_id":"DKgx28KbdPfz****",
            "name":"早上",
            "background":"https://images.tuyacn.com/smart/rule/cover/****.png",
            "actions":[
                {
                    "entity_id":"012000715ccf7f4f****",
                    "executor_property":{
                        "switch_led":true
                    },
                    "action_executor":"dpIssue"
                }
            ]
        }
    ]
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 权限非法 | 
查询默认场景图⽚列表。
GET /v1.0/scenes/default-pictures
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | List | 返回场景图⽚地址列表。 | 
GET /v1.0/scenes/default-pictures
{
   "success":true,
   "t":1541071460239,
   "result":[
       "https://images.tuyacn.com/smart/rule/cover/starry.png",
       "https://images.tuyacn.com/smart/rule/cover/sport.png"
   ]
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 权限非法 | 
触发执行某个场景。
POST /v1.0/homes/{home_id}/scenes/{scene_id}/trigger
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 家庭 ID | 是 | 
| scene_id | String | URI | 场景 ID | 是 | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | Object | 场景触发是否成功,成功返回 true。 | 
POST /v1.0/homes/242****/scenes/53IYSXI3gEn2w3Oc/trigger
{
 "success": true,
 "t": 1541072348540,
 "result": true
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 权限非法 | 
删除家庭下的某个场景。
DELETE /v1.0/homes/{home_id}/scenes/{scene_id}
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 家庭 ID | 是 | 
| scene_id | String | URI | 场景 ID | 是 | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | Object | 场景删除成功,返回true。 | 
DELETE /v1.0/homes/242****/scenes/53IYSXI3gEn2****
{
 "success": true,
 "t": 1541072348540,
 "result": true
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 权限非法 | 
给某个家庭下添加场景。
POST /v1.0/homes/{home_id}/scenes
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | String | URI | 家庭 ID | 是 | 
| name | String | Body | 场景名称 | 是 | 
| background | String | Body | 背景图片 | 是 | 
| actions | List | Body | 动作列表 | 是 | 
Action 中设备相关说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_id | String | 目标 ID。 | 是 | 
| executor_property | JSON | 执⾏动作参数。 | 否 | 
| action_executor | String | 执⾏动作类别。 | 是 | 
Action 相关说明
设备动作
entity_id:设备 IDaction_executor:dpIssueexecutor_property:标准指令延时动作
entity_id:设备 IDaction_executor:delayexecutor_property:延时参数禁用自动化
entity_id:自动化 IDaction_executor:ruleDisableexecutor_property:不填启用自动化
entity_id:自动化 IDaction_executor:ruleEnableexecutor_property:不填| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | Object | 场景 ID。 | 
POST /v1.0/homes/242****/scenes
{
    "name":"添加场景测试",
    "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****"
        },
	{
                    "action_executor": "ruleDisable",
                    "entity_id": "AYJV2hh3eqm3****"
         },
	{
                    "action_executor": "ruleEnable",
                    "entity_id": "AYJV2hh3eqm3****"
         }
    ]
}
{
 "success": true,
 "t": 1541072348540,
 "result":"53IYSXI3gEn2****"
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 权限非法 | 
修改某个家庭下的场景。
PUT /v1.0/homes/{home_id}/scenes/{scene_id}
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 家庭 ID | 是 | 
| scene_id | String | Body | 场景 ID | 是 | 
| name | String | Body | 场景名称 | 是 | 
| background | String | Body | 背景图片 | 是 | 
| actions | List | Body | 动作列表 | 是 | 
Action 中设备相关说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_id | String | 设备 ID。 | 是 | 
| executor_property | JSON | 执⾏动作参数。 | 是 | 
| action_executor | String | 执⾏动作类别,例如,dpIssue。 | 
是 | 
Action 中延时相关说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| executor_property | JSON | 执⾏动作参数。 | 是 | 
| action_executor | String | 执⾏动作类别,例如,delay。 | 
是 | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | Object | 修改成功返回 true。 | 
PUT /v1.0/homes/242****/scenes/53IYSXI3gEn2****    
{
    "name":"添加场景测试",
    "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****"
        }
    ]
}
{
 "success": true,
 "t": 1541072348540,
 "result": true
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 权限非法 | 
查询家庭下支持场景的设备列表。
GET /v1.0/homes/{home_id}/scene/devices
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 用户家庭 ID | 是 | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | List | 返回结果。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| device_id | String | 设备编号 | 
| uuid | String | 设备唯一标识 | 
| name | String | 名称 | 
| home_id | String | 家庭 ID | 
| product_id | String | 产品 ID | 
GET /v1.0/homes/2422121/scene/devices
{
    "result":[
    	{
    		"id":"vedo123****",
    		"uuid":"asdfghnbvcx****",
        	"name":"测试设备",
    		"product_id":"r4567543****",
    		"home_id":"242****"
    	}
    ],
    "success":true,
    "t":1572936751228
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
接口主要适用于场景开关设备。场景开关有相应的开关按钮,每个开关按钮拥有相应的指令。通过该接口,可以将指定的开关指令与场景进行绑定,即场景开关与场景进行关联操作。绑定成功后,通过指令下发接口,可以直接触发场景。
POST /v1.0/devices/{device_id}/scenes/{scene_id}
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| scene_id | String | URI | 场景 ID | 是 | 
| device_id | String | URI | 设备 ID | 是 | 
| code | String | Body | 标准指令 Code | 是 | 
| value | String | BODY | 指令入参范围 | 是 | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | Long | 房间 ID,room_id。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| Success | Boolean | 执行成功或失败 | 
POST /v1.0/devices/vdevo1575XXXX00013095/scenes/EqFkQ79XXXXXtjlkTm
{
	"code":"scene_1",
	"value":"scene"
}
{
    "result": {
        "success": true
    },
    "success": true,
    "t": 1575972372805
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 权限非法 | 
接口主要适用于场景开关设备。场景开关中的某个开关与指定场景绑定后,可通过该接口进行解绑。
DELETE /v1.0/devices/{device_id}/scenes/{scene_id}
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| device_id | String | URI | 设备 ID | 是 | 
| scene_id | String | URI | 场景 ID | 是 | 
| code | String | BODY | 标准指令 Code,该值与场景开关按钮一一对应。 | 是 | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | Long | 房间 ID,room_id。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| Success | Boolean | 执行成功或失败 | 
DELETE /v1.0/devices/vdevo1575XXXX00013095/scenes/EqFkQ79XXXXXtjlkTm
{
	"code":"scene_1"
}
{
    "result": {
        "success": true
    },
    "success": true,
    "t": 1575972372805
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 权限非法 | 
接口主要适用于场景开关设备。通过场景开关设备 ID,查询该设备所关联的场景列表。
GET /v1.0/devices/{device_id}/scenes
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| device_id | String | URI | 设备 ID | 是 | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功为空。 | 
| result | Long | 房间 ID,room_id。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| device_id | Boolean | 设备 ID | 
| scenes | Object | 已绑定的场景列表 | 
Scenes
| 参数名 | 类型 | 说明 | 
|---|---|---|
| scene_id | String | 场景 ID。 | 
| name | String | 场景名称。 | 
| code | String | 绑定指令。场景的开关设备,一个开关对应一个标准指令。 | 
| value | Object | 指令入参范围。 | 
GET /v1.0/devices/vdevo15758XXXX13095/scenes
{
    "result": {
        "device_id": "vdevo15758****13095",
        "scenes": [
            {
                "code": "scene_2",
                "name": "添加场景G测试-关灯",
                "scene_id": "ilCZllmb***POY36",
                "value": "scene"
            },***
            {
                "code": "scene_1",
                "name": "灯泡开场景",
                "scene_id": "EqFkQ79u***jlkTm",
                "value": "scene"
            }
        ]
    },
    "success": true,
    "t": 1576036860284
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
| 1106 | 权限非法 | 
为家庭添加自动化功能。
POST /v1.0/homes/{home_id}/automations
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 用户家庭 ID。 | 是 | 
| name | String | Body | 自动化名称。 | 是 | 
| background | String | Body | 背景图片。 | 是 | 
| conditions | List | Body | 条件列表。 | 是 | 
| actions | List | Body | 动作列表。 | 是 | 
| match_type | Integer | Body | 匹配类型:
  | 
是 | 
| condition_rule | String | String | 自定义条件规则,当匹配类型 match_type 是 3,该参数必填。自定义条件规则遵从与或运算公式。每个自动化条件以其 order_num 为标识码。 | 
否 | 
| preconditions | List | Body | 前置条件,优先级最高。 | 否 | 
说明: 例如,
condition_rule中order_num依次为 1,2 和 3,业务场景为:条件 1 与 2 同时满足,或者条件 3 满足的情况下触发自动化,则表达式为:1&&2||3。
Conditions
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_type | Integer | 条件类型。目前支持以下类型:
  | 
是 | 
| display | JSON | 条件展示。 | 是 | 
| order_num | Integer | 条件排序,从 1 开始。 | 是 | 
| entity_id | String | 执行动作实体: 
  | 
否 | 
Display 设备状态条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 设备的 statusCode。 | 
是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | String | Code 的取值。 | 是 | 
Display 外部条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 外部条件的 Key。 | 是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | Object | 外部条件的 Key 对应 Code 的取值。 | 是 | 
Display 天气条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 天气条件对应的 Key,例如温度 temp。 | 
是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | String | 天气条件对应的 Key 对应 Code 的取值。 | 是 | 
Display 定时条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| date | String | 触发日期,格式为yyyyMMdd,例如20191125。 | 
是 | 
| loops | String | 由 0 和 1 组成的 7 位数字。0 表示不执行,1 表示执行。第 1 位为周日,依次表示周一至周六。例如,0011000表示每周二,周三执行。 | 
是 | 
| time | String | 触发时间,24 小时制,示例:14:00。 | 
是 | 
| timezone_id | String | 时区 ID,示例:Asia/Shanghai。 | 
是 | 
Preconditions 说明
前置限制条件,目前支持时间段限制。
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| cond_type | String | 当前仅支持时间段限制,固定为timeCheck。 | 
是 | 
| display | JSON | 条件展示。 | 是 | 
Preconditions 中 Display 说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| start | String | 开始时间,默认为当天的某个时间点,24小时制。示例:10:00。 | 
是 | 
| end | String | 结束时间,24小时制。示例:22:00。 | 
是 | 
| loops | String | 由 0 和 1 组成的 7 位数字。0 表示不执行,1 表示执行。第 1 位为周日,依次表示周一至周六。例如,0011000表示每周二,周三执行。 | 
是 | 
| timezone_id | String | 时区 ID,示例:Asia/Shanghai。 | 
是 | 
Action相关说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_id | String | 目标 ID。 | 是 | 
| executor_property | JSON | 执行动作参数。 | 否 | 
| action_executor | String | 执行动作类别。 | 是 | 
设备动作
entity_id:设备 IDaction_executor:dpIssueexecutor_property:标准指令禁用自动化
entity_id:自动化 IDaction_executor:ruleDisableexecutor_property:不填启用自动化
entity_id:自动化 IDaction_executor:ruleEnableexecutor_property:不填触发场景
entity_id:场景 IDaction_executor:ruleTriggerexecutor_property:不填POST /v1.0/homes/242****/automations
{
    "conditions":[
        {
            "display":{
                "code":"switch_1",
                "operator":"==",
                "value":true
            },
            "entity_id":"vdevo15725982542****",
            "entity_type":1,
            "order_num":1
        }
    ],
    "actions":[
    {
                "action_executor":"delay",
                "executor_property":{
    			  "hours": "0",
    			  "minutes": "0",
    			  "seconds": "5"
                }
            },
        {
            "action_executor":"dpIssue",
          	"entity_id":"vdevo15725982542****",
            "executor_property":{
			  "switch_1": true
            }
        }
    ],
    "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
    "match_type":1,
    "name":"测试自动化"
}
前置条件示例
{
    "preconditions":[
        {
            "display":{
                "start":"10:00",
                "end":"12:00",
                "loops":"0010000",
                "timezone_id":"Asia/Shanghai"
            },
            "cond_type":"timeCheck"
        }
    ]
}
设备状态条件示例
{
    "conditions":[
        {
            "display":{
                "code":"switch_1",
                "operator":"==",
                "value":true
            },
            "entity_id":"vdevo15725982542****",
            "entity_type":1,
            "order_num":1
        }
    ]
}
外部条件示例
{
    "conditions":[
        {
            "display":{
                "code":"test",
                "operator":"==",
                "value":"test"
            },
            "entity_type":15,
            "order_num":1
        }
    ]
}
天气条件示例
{
  "conditions":[
        {
            "display":{
                "code":"temp",
                "operator":"==",
                "value":"20"
            },
            "entity_id":"10",
            "entity_type":3,
            "order_num":1
        }
    ]
}
定时条件示例
{
  "conditions":[
        {
            "display":{
                "date":"20200301",
                "loops":"0000000",
                "time":"14:00",
                "timezone_id":"Asia/Shanghai"
            },
            "entity_id":"timer",
            "entity_type":6,
            "order_num":1
        }
    ]
}
外部动作示例
{
    "actions":[
        {
            "action_executor":"externalAction",
            "executor_property":{
              //自定义,将通过消息队列推送
            }
        }
    ]
}
Code 的数据类型和操作符的映射说明
| type | operator | 
|---|---|
| Boolean | “==” | 
| Integer | “>”,“==”,“<” | 
| Enum | “==” | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | String | 自动化 ID。 | 
{
    "success": true,
    "t": 1541072348540,
    "result":"53IYSXI3gEn2w3Oc"
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
修改家庭的自动化配置。
PUT /v1.0/homes/{home_id}/automations/{automation_id}
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 用户家庭 ID | 是 | 
| automation_id | String | URI | 自动化 ID。 | 是 | 
| name | String | Body | 自动化名称。 | 是 | 
| background | String | Body | 背景图片。 | 是 | 
| conditions | List | Body | 条件列表。 | 是 | 
| actions | List | Body | 动作列表。 | 是 | 
| match_type | Integer | Body | 匹配类型。
  | 
是 | 
| condition_rule | String | String | 自定义条件规则。当匹配类型 match_type 是 3,该参数必填。自定义条件规则遵从与或运算公式。每个自动化条件以其 order_num 为标识码。 | 
否 | 
| preconditions | List | Body | 前置条件,优先级最高。 | 否 | 
说明: 例如,
condition_rule中order_num依次为 1,2 和 3,业务场景为:条件 1 与 2 同时满足,或者条件 3 满足的情况下触发自动化,则表达式为:1&&2||3。
Conditions
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_type | Integer | 条件类型。目前支持以下类型:
  | 
是 | 
| display | JSON | 条件展示。 | 是 | 
| order_num | Integer | 条件排序,从 1 开始。 | 
是 | 
| entity_id | String | 执行动作实体。 
  | 
否 | 
Display 设备状态条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 设备的 statusCode。 | 
是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | String | Code 的取值。 | 是 | 
Display 外部条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 外部条件的 Key。 | 是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | Object | 外部条件的 Key 对应 Code 的取值。 | 是 | 
Display 天气条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 天气条件对应的 Key,例如温度 temp。 | 
是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | String | 天气条件对应的 Key 对应 Code 的取值。 | 是 | 
Display 定时条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| date | String | 触发日期,格式为 yyyyMMdd,例如 20191125。 | 
是 | 
| loops | String | 由 0 和 1 组成的 7 位数字。0 表示不执行,1 表示执行。第 1 位为周日,依次表示周一至周六。例如,0011000表示每周二,周三执行。 | 
是 | 
| time | String | 触发时间,24 小时制。示例:14:00。 | 
是 | 
| timezone_id | String | 时区 ID。示例:Asia/Shanghai。 | 
是 | 
Preconditions 说明
前置限制条件,目前支持时间段限制。
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| cond_type | String | 当前仅支持时间段限制,固定为 timeCheck。 | 
是 | 
| display | JSON | 条件展示。 | 是 | 
Preconditions 中 Display 说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| start | String | 开始时间,默认为当天的某个时间点,24 小时制。示例:10:00。 | 
是 | 
| end | String | 结束时间,24 小时制。示例:22:00。 | 
是 | 
| loops | String | 由 0 和 1 组成的 7 位数字。0 表示不执行,1 表示执行。第 1 位为周日,依次表示周一至周六。例如,0011000 表示每周二,周三执行。 | 
是 | 
| timezone_id | String | 时区 ID,示例:Asia/Shanghai。 | 
是 | 
Actions 设备说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_id | String | 设备 ID。 | 是 | 
| executor_property | JSON | 执行动作参数。 | 是 | 
| action_executor | String | 执行动作类别,固定为 dpIssue。 | 
是 | 
Actions 外部动作说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| executor_property | JSON | 自定义外部动作。 | 是 | 
| action_executor | String | 执行动作类别,固定为 externalAction。 | 
是 | 
Actions 延时说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| executor_property | JSON | 执行动作参数。 | 是 | 
| action_executor | String | 执行动作类别,固定为 delay。 | 
是 | 
PUT /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc
{
            "actions":[
               {
                                   "action_executor":"delay",
                                   "executor_property":{
                                   	"hours":"0",
                                   	"minutes": "0",
                                   	"seconds": "5"
                                   }
                                
                               },
                {
                    "action_executor":"dpIssue",
                    "entity_id":"vdevo157259825422***",
                    "executor_property":{
                    	"switch_1":true
                    }
                 
                },
              	{
                    "action_executor":"externalAction",
                    "executor_property":{
                    	// 用户自定义
                    }
                 
                }
            ],
          
            "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
            "conditions":[
               
               {
                    "display":{
                        "code":"switch_1",
                        "operator":"==",
                        "value":true
                    },
                    "entity_id":"vdevo157259825422***",
                    "entity_type":1,
                    "order_num":1
                },
                {
                    "display":{
                        "code":"mode",
                        "operator":"==",
                        "value":1
                    },
                    "entity_type":15,
                    "order_num":2
                }
            ],
            "match_type":1,
            "name":"测试自动化"
        }
前置条件示例
{
    "preconditions":[
        {
            "display":{
                "start":"10:00",
                "end":"12:00",
                "loops":"0000000",
                "timezone_id":"Asia/Shanghai"
            },
            "cond_type":"timeCheck"
        }
    ]
}
设备状态条件示例
{
    "conditions":[
        {
            "display":{
                "code":"switch_1",
                "operator":"==",
                "value":true
            },
            "entity_id":"vdevo157259825422***",
            "entity_type":1,
            "order_num":1
        }
    ]
}
外部条件示例
{
    "conditions":[
        {
            "display":{
                "code":"test",
                "operator":"==",
                "value":"test"
            },
            "entity_type":15,
            "order_num":1
        }
    ]
}
天气条件示例
{
  "conditions":[
        {
            "display":{
                "code":"temp",
                "operator":"==",
                "value":"20"
            },
            "entity_id":"10",
            "entity_type":3,
            "order_num":1
        }
    ]
}
定时条件示例
{
  "conditions":[
        {
            "display":{
                "date":"20200301",
                "loops":"0000000",
                "time":"14:00",
                "timezone_id":"Asia/Shanghai"
            },
            "entity_id":"timer",
            "entity_type":6,
            "order_num":1
        }
    ]
}
外部动作示例
{
    "actions":[
        {
            "action_executor":"externalAction",
            "executor_property":{
              //自定义,将通过消息队列推送
            }
        }
    ]
}
延时动作示例
{
   "action_executor":"delay",
   "executor_property":{
    "hours":"0",
    "minutes": "0",
    "seconds": "5"
   }
}
Code 的数据类型和操作符的映射说明
| type | operator | 
|---|---|
| Boolean | “==” | 
| Integer | “>”,“==”,“<” | 
| Enum | “==” | 
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | String | 修改成功返回 true。 | 
{
    "success": true,
    "t": 1541072348540,
    "result": true
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
删除家庭的自动化配置。
DELETE /v1.0/homes/{home_id}/automations/{automation_id}
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 用户家庭 ID | 是 | 
| automation_id | String | URI | 自动化 ID | 是 | 
DELETE /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | String | 自动化删除是否成功,成功返回 true。 | 
{
    "success": true,
    "t": 1541072348540,
    "result":true
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
查询自动化列表。
GET /v1.1/homes/{home_id}/automations
| 参数名 | 类型 | 参数类型 | 说明 | 必须 | 
|---|---|---|---|---|
| home_id | Long | URI | 用户家庭 ID | 是 | 
GET /v1.1/homes/242****/automations
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | List | 返回结果。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| automation_id | String | 自动化 ID。 | 
| name | String | 自动化名称。 | 
| enabled | Boolean | 启用状态。 | 
| status | String | 状态。1:正常,2:失效 | 
| background | String | 背景图片。 | 
| conditions | List | 条件列表。 | 
| preconditions | List | 前置条件。 | 
| actions | List | 动作列表。 | 
| match_type | Integer | 匹配类型。
  | 
| condition_rule | String | 自定义条件规则。当匹配类型 match_type 是 3,该参数必填。自定义条件规则遵从与或运算公式。每个自动化条件以其 order_num 为标识码。 | 
Conditions
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_type | Integer | 条件类型。目前支持以下类型:
  | 
是 | 
| display | JSON | 条件展示。 | 是 | 
| order_num | Integer | 条件排序,从 1 开始。 | 
是 | 
| entity_id | String | 执行动作实体: 
  | 
否 | 
Display 设备状态条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 设备的 statusCode。 | 
是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | String | Code 的取值。 | 是 | 
Display 外部条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 外部条件的 Key。 | 是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | Object | 外部条件的 Key 对应 Code 的取值。 | 是 | 
Display 天气条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 天气条件对应的 Key,例如温度 temp。 | 
是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | String | 天气条件对应的 Key 对应 Code 的取值。 | 是 | 
Display 定时条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| date | String | 触发日期,格式为yyyyMMdd,例如20191125。 | 
是 | 
| loops | String | 由 0 和 1 组成的 7 位数字。0 表示不执行,1 表示执行。第 1 位为周日,依次表示周一至周六。例如,0011000表示每周二,周三执行。 | 
是 | 
| time | String | 触发时间,24 小时制。示例:14:00。 | 
是 | 
| timezone_id | String | 时区 ID。示例:Asia/Shanghai。 | 
是 | 
Preconditions 说明
前置限制条件,目前支持时间段限制。
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| cond_type | String | 当前仅支持时间段限制,固定为 timeCheck。 | 
是 | 
| display | JSON | 条件展示。 | 是 | 
Preconditions 中 Display 说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| start | String | 开始时间,默认为当天的某个时间点,24小时制。示例:10:00。 | 
是 | 
| end | String | 结束时间,24小时制。示例:22:00。 | 
是 | 
| loops | String | 由 0 和 1 组成的 7 位数字。0 表示不执行,1 表示执行。第 1 位为周日,依次表示周一至周六。例如,0011000表示每周二,周三执行。 | 
是 | 
| timezone_id | String | 时区 ID。示例:Asia/Shanghai。 | 
是 | 
Actions 设备说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_id | String | 设备 ID。 | 是 | 
| executor_property | JSON | 执行动作参数。 | 是 | 
| action_executor | String | 执行动作类别,固定为 dpIssue。 | 
是 | 
Actions 外部动作说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| executor_property | JSON | 自定义外部动作。 | 是 | 
| action_executor | String | 执行动作类别,固定为 externalAction。 | 
是 | 
Code 的数据类型和操作符的映射说明
| type | operator | 
|---|---|
| Boolean | “==” | 
| Integer | “>”,“==”,“<” | 
| Enum | “==” | 
{
    "result":[
        {
            "actions":[
                {
                   "action_executor":"delay",
                   "executor_property":{
                    "hours":"0",
                    "minutes": "0",
                    "seconds": "5"
                   }
                
                },
                {
                    "action_executor":"dpIssue",
                    "entity_id":"vdevo157259825422***",
                    "executor_property":{
                        "switch_1":true
                    }
                },
              	{
                    "action_executor":"externalAction",
                    "executor_property":{
                    	// 用户自定义
                    }
                 
                }
            ],
            "automation_id":"p2aWOkEOe2RzA***",
            "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
            "conditions":[
                {
                    "display":{
                        "code":"switch_1",
                        "operator":"==",
                        "value":true
                    },
                    "entity_id":"vdevo157259825422***",
                    "entity_type":1,
                    "order_num":1
                }
            ],
            "enabled": true,
            "status": "1",
            "match_type":1,
            "name":"测试自动化"
        },
        {
            "automation_id":"L07BQVabdqwFP***",
            "background":"https://images.tuyacn.com/smart/rule/cover/house6.png",
            "conditions":[
                {
                    "display":{
                        "code":"battery_percentage",
                        "operator":"<",
                        "value":255
                    },
                    "entity_id":"vdevo156958314001***",
                    "entity_type":1,
                    "order_num":1
                },
                {
                    "display":{
                        "code":"mode",
                        "operator":"==",
                        "value":1
                    },
                    "entity_id":"weqszcaokqlmlkmlcanqklwokl***",
                    "entity_type":15,
                    "order_num":2
                }
            ],
            "enabled": true,
            "match_type":1,
            "name":"自动化测试1"
        }
    ],
    "success":true,
    "t":1572936751228
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
查询家庭中单个自动化场景。
GET /v1.0/homes/{home_id}/automations/{automation_id}
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 用户家庭 ID | 是 | 
| automation_id | String | URI | 自动化场景 ID | 是 | 
GET /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | Object | 返回结果。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| automation_id | String | 自动化场景 ID。 | 
| name | String | 自动化场景名称。 | 
| enabled | Boolean | 启用状态。 | 
| background | String | 背景图片。 | 
| conditions | List | 条件列表。 | 
| preconditions | List | 前置条件。 | 
| actions | List | 动作列表。 | 
| match_type | Integer | 匹配类型。
  | 
| condition_rule | String | 自定义条件规则。当匹配类型 match_type 是 3,该参数必填。自定义条件规则遵从与或运算公式。每个自动化条件以其 order_num 为标识码。 | 
Conditions
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_type | Integer | 条件类型。目前支持以下类型:
  | 
是 | 
| display | JSON | 条件展示。 | 是 | 
| order_num | Integer | 条件排序,从 1 开始。 | 
是 | 
| entity_id | String | 执行动作实体: 
  | 
否 | 
Display 设备状态条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 设备的 statusCode。 | 
是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | String | Code 的取值。 | 是 | 
Display 外部条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 外部条件的 Key。 | 是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | Object | 外部条件的 Key 对应 Code 的取值。 | 是 | 
Display 天气条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 天气条件对应的 Key,例如温度 temp。 | 
是 | 
| operator | String | 操作符,参考 Code 的数据类型和操作符的映射说明。 | 是 | 
| value | String | 天气条件对应的 Key 对应 Code 的取值。 | 是 | 
Display 定时条件说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| date | String | 触发日期,格式为yyyyMMdd,例如20191125。 | 
是 | 
| loops | String | 由 0 和 1 组成的 7 位数字。0 表示不执行,1 表示执行。第 1 位为周日,依次表示周一至周六。例如,0011000 表示每周二,周三执行。 | 
是 | 
| time | String | 触发时间,24 小时制。示例:14:00。 | 
是 | 
| timezone_id | String | 时区 ID。示例:Asia/Shanghai。 | 
是 | 
Preconditions 说明
前置限制条件,目前支持时间段限制。
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| cond_type | String | 当前仅支持时间段限制,固定为timeCheck。 | 
是 | 
| display | JSON | 条件展示。 | 是 | 
Preconditions 中 Display 说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| start | String | 开始时间,默认为当天的某个时间点,24小时制。示例:10:00。 | 
是 | 
| end | String | 结束时间,24小时制。示例:22:00。 | 
是 | 
| loops | String | 由 0 和 1 组成的 7 位数字。0 表示不执行,1 表示执行。第 1 位为周日,依次表示周一至周六。例如,0011000 表示每周二,周三执行。 | 
是 | 
| timezone_id | String | 时区 ID。示例:Asia/Shanghai。 | 
是 | 
Actions 设备说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_id | String | 设备 ID。 | 是 | 
| executor_property | JSON | 执行动作参数。 | 是 | 
| action_executor | String | 执行动作类别,固定为 dpIssue。 | 
是 | 
Actions 外部动作说明
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| executor_property | JSON | 自定义外部动作。 | 是 | 
| action_executor | String | 执行动作类别,固定为 externalAction。 | 
是 | 
Code 的数据类型和操作符的映射说明
| type | operator | 
|---|---|
| Boolean | “==” | 
| Integer | “>”,“==”,“<” | 
| Enum | “==” | 
{
    "result":[{
            "actions":[
                {
                   "action_executor":"delay",
                   "executor_property":{
                    "hours":"0",
                    "minutes": "0",
                    "seconds": "5"
                   }
                
                },
                {
                    "action_executor":"dpIssue",
                    "entity_id":"vdevo157259825422***",
                    "executor_property":{
                        "switch_1":true
                    }
                },
                {
                    "action_executor":"externalAction",
                    "executor_property":{
                        // 用户自定义
                    }
                 
                }
            ],
            "automation_id":"p2aWOkEOe2RzA***",
            "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
            "conditions":[
                {
                    "display":{
                        "code":"switch_1",
                        "operator":"==",
                        "value":true
                    },
                    "entity_id":"vdevo157259825422***",
                    "entity_type":1,
                    "order_num":1
                }
            ],
            "enabled": true,
            "match_type":1,
            "name":"测试自动化"
        },
        {
            "automation_id":"L07BQVabdqwFP***",
            "background":"https://images.tuyacn.com/smart/rule/cover/house6.png",
            "conditions":[
                {
                    "display":{
                        "code":"battery_percentage",
                        "operator":"<",
                        "value":255
                    },
                    "entity_id":"vdevo156958314001***",
                    "entity_type":1,
                    "order_num":1
                },
                {
                    "display":{
                        "code":"mode",
                        "operator":"==",
                        "value":1
                    },
                    "entity_id":"weqszcaokqlmlkmlcanqklwoklj***",
                    "entity_type":15,
                    "order_num":2
                }
            ],
            "enabled": true,
            "match_type":1,
            "name":"自动化测试1"
        },
    "success":true,
    "t":1572936751228
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
触发家庭中自动化场景的外部条件。
POST /v1.0/homes/{home_id}/automations/{automation_id}/conditions/trigger
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 用户家庭 ID | 是 | 
| automation_id | String | URI | 自动化场景 ID | 是 | 
| conditions | List | Body | 条件列表 | 是 | 
Conditions
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| entity_id | String | 外部条件对应 ID | 是 | 
| display | JSON | 条件 | 是 | 
Display
| 参数名 | 类型 | 说明 | 必填 | 
|---|---|---|---|
| code | String | 设备的 statusCode | 
是 | 
| value | String | Code 的取值 | 是 | 
POST /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc/conditions/trigger
[{
	"entity_id":"c9a5a524-d973-4b59-9390-0dcda0f17***",
	"display":{
		"code":"test",
		"value":"test"
	}
}]
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | String | 场景触发是否成功,成功返回 true。 | 
{
    "success": true,
    "t": 1541072348540,
    "result": true
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
查询家庭下支持自动化场景的设备列表。
GET /v1.0/homes/{home_id}/automation/devices
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | Long | URI | 用户家庭 ID | 是 | 
| type | String | URL | 支持的类型。
  | 
否 | 
不输出 type 参数即返回所有支持自动化场景的设备。
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | List | 返回结果。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| device_id | String | 设备编号 | 
| uuid | String | 设备唯一标识 | 
| name | String | 名称 | 
| home_id | String | 家庭 ID | 
| product_id | String | 产品 ID | 
GET /v1.0/homes/242****/automation/devices?type=condition
{
    "result":[
    	{
    		"id":"vedo123****",
    		"uuid":"asdfghnbvcx****",
        "name":"测试设备",
    		"product_id":"r4567543****",
    		"home_id":"242****"
    	}
    ],
    "success":true,
    "t":1572936751228
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
查询自动化支持的天气条件。
GET /v1.0/homes/automation/weather/conditions
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | List | 返回结果。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| category | String | 类别 | 
| category_name | String | 类别名称 | 
| operators | String | 操作符 | 
| property | JSON | 类别属性 | 
GET /v1.0/homes/automation/weather/conditions
{
    "result":[
    		{
    			"category":"temp",
    			"category_name":"温度",
    			"operators":"[\"<\",\"==\",\">\"]",
    			"property":{
                    "unit": "℃",
                    "min": -40,
                    "max": 40,
                    "step": 1,
                    "type": "value"
                },
    		}
    ],
    "success":true,
    "t":1572936751228
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
根据家庭 ID,获取联动条件或执行动作的标准功能点。
GET /v1.0/homes/{home_id}/enable-linkage/codes
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| home_id | String | URI | 家庭 ID | 是 | 
GET /v1.0/homes/5232322/enable-linkage/codes
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | List | 返回结果。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| device_id | String | 自动化设备 ID。 | 
| functions | List | 执行的操作。 | 
| status | List | 操作触发的条件。 | 
Functions
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | String | 标准下发指令 Code。 | 
| name | String | Code 名称。 | 
| type | String | 下发数据类型。目前支持以下三种类型:
  | 
| values | JSON | Code 对应的取值范围。 | 
Status
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | String | 标准上报状态 Code。 | 
| name | String | Code 名称。 | 
| type | String | 上报数据类型,目前支持以下三种类型:
  | 
| values | JSON | Code 对应的取值范围。 | 
{
    "success": true,
    "t": 1541072348540,
    "result": [
                {
                  "device_id": "0120090568c63a89c***",
                  "functions": [
                      {
                          "name": "亮度",
                          "code": "bright_value",
                          "type": "Integer",
                          "values": {
                                        "max":255,
                                        "min":25,
                                        "scale":0,
                                        "step":1,
                                        "type":"value",
                                        "unit":""
                                    }
                      },
                      {
                        "name": "开关",
                        "code": "switch_led",
                        "type": "Boolean"
                    }
                  ],
                  "status": [
                      {
                          "name": "模式",
                          "code": "work_mode",
                          "type": "Enum",
                          "values":  {
                                        "range": [
                                                    "white",
                                                    "colour",
                                                    "scene",
                                                    "scene_1",
                                                    "scene_2",
                                                    "scene_3",
                                                    "scene_4"
                                                ],
                                         "type": "Enum"
                                    }
                      }
                  ]
                }
            ]
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
根据设备 ID,获取联动条件或执行动作的标准功能点。
GET /v1.0/devices/{device_id}/enable-linkage/codes
| 参数名 | 类型 | 参数类型 | 说明 | 必填 | 
|---|---|---|---|---|
| device_id | String | URI | 设备 ID | 是 | 
GET /v1.0/devices/0120090568c63a89cb34/enable-linkage/codes
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | Object | 返回结果。 | 
Result
| 参数名 | 类型 | 说明 | 
|---|---|---|
| device_id | String | 设备 ID。 | 
| functions | List | 执行动作的标准指令。 | 
| status | List | 触发动作的标准状态。 | 
Functions
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | String | 标准下发指令 Code。 | 
| name | String | Code 名称。 | 
| type | String | 下发数据类型,目前支持以下三种类型:
  | 
| values | JSON | Code 对应的取值范围。 | 
Status
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | String | 标准上报状态 Code。 | 
| name | String | Code 名称。 | 
| type | String | 上报数据类型,目前支持以下三种类型:
  | 
| values | JSON | Code 对应的取值范围。 | 
{
    "success": true,
    "t": 1541072348540,
    "result": {
                  "device_id": "0120090568c63a89c***",
                  "functions": [
                      {
                          "name": "亮度",
                          "code": "bright_value",
                          "type": "Integer",
                          "values": {
                                        "max":255,
                                        "min":25,
                                        "scale":0,
                                        "step":1,
                                        "type":"Integer",
                                        "unit":""
                                    }
                      },
                      {
                        "name": "开关",
                        "code": "switch_led",
                        "type": "Boolean",
                        "values": {
                                    "type": "Boolean"
                                  }
                    }
                  ],
                  "status": [
                      {
                          "name": "模式",
                          "code": "work_mode",
                          "type": "Enum",
                          "values":  {
                                        "range": [
                                                    "white",
                                                    "colour",
                                                    "scene",
                                                    "scene_1",
                                                    "scene_2",
                                                    "scene_3",
                                                    "scene_4"
                                                ],
                                         "type": "Enum"
                                    }
                      }
                  ]
            }
}
{
    "success": false,
    "code": 1100,
    "msg": "param is empty",
    "t": 1540954683193
}
启用自动化场景。
PUT /v1.0/homes/{home_id}/automations/{automation_id}/actions/enable
| 参数名 | 类型 | 参数类型 | 说明 | 是否必需 | 
|---|---|---|---|---|
| home_id | Long | 家庭 ID | URI | 是 | 
| automation_id | String | 自动化场景 ID | URI | 是 | 
返回参数:
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | Boolean | 返回结果。 | 
PUT /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc/actions/enable
{
    "success": true,
    "t": 1541072348540,
    "result": true
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
停用自动化场景。
PUT /v1.0/homes/{home_id}/automations/{automation_id}/actions/disable
| 参数名 | 类型 | 参数类型 | 说明 | 是否必需 | 
|---|---|---|---|---|
| home_id | Long | 家庭 ID | URI | 是 | 
| automation_id | String | 自动化场景 ID | URI | 是 | 
返回参数:
| 参数名 | 类型 | 说明 | 
|---|---|---|
| code | Integer | 响应码。更多信息,请参考 全局错误码。 | 
| success | Boolean | 是否成功。
  | 
| msg | String | 请求失败的信息,请求成功时为空。 | 
| t | Long | 返回 13 位时间戳。 | 
| result | Boolean | 返回结果。 | 
PUT /v1.0/homes/242****/automations/53IYSXI3gEn2w3Oc/actions/disable
{
    "success": true,
    "t": 1541072348540,
    "result": true
}
以下为该接口常见的业务异常。更多的异常错误,请参考 全局错误码。
| 错误码 | 说明 | 
|---|---|
| 500 | 系统错误 | 
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈