更新时间:2023-12-07 03:33:57下载pdf
本文介绍添加自动化的 API。
为家庭添加自动化功能。
POST: /v1.0/homes/{home_id}/automations
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 |
|---|---|---|---|---|
| home_id | String | uri | true | 家庭 ID。 |
body 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 |
|---|---|---|---|---|
| automation_id | String | body | false | 自动化 ID。 |
| name | String | body | true | 自动化名称。 |
| match_type | Integer | body | true | 匹配类型。
|
| background | String | body | true | 背景图片。 |
| conditions | List | body | true | 条件集合。 |
| actions | List | body | true | 动作集合。 |
conditions 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 |
|---|---|---|---|---|
| entity_id | String | body | true | 实体 ID。可能是设备 ID、天气、温度等 |
| entity_type | Integer | body | true | 条件对象类型。
|
| order_num | Integer | body | true | 顺序码,不可重复。 |
| display | Expr | body | true | 计算表达式。 |
actions 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 |
|---|---|---|---|---|
| entity_id | String | body | false | 实体 ID。可能是设备 ID、天气、温度等 |
| action_executor | String | body | true | 动作对象类型。
|
| executor_property | ExecutorProperty | body | true | 动作明细。 |
display 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 |
|---|---|---|---|---|
| code | String | body | true | 状态集 code。当 entity_type 是 1 或 3 时,此参数必填。如果entity_type 为 3 时,值需要定义为以下值之一$temp、$humidity、$condition、$pm25、$aqi、$windSpeed、$sunsetrise,更详细的天气内容请查询提天气码 API |
| operator | String | body | true | 比较表达式。当 entity_type 是 1 或 3 时,此参数必填。
|
| value | Object | body | true | 状态集 value。当 entity_type 是 1 或 3 时,此参数必填。 |
| date | String | body | false | 自动化规则触发日期。 |
| time | String | body | true | 自动化规则触发时间。 |
| loops | String | body | false | 触发周期,由 0 和 1 组成的 7 位数字。0 表示不执行,1 表示执行。第 1 位为周日,依次表示周一至周六。例如,0011000 表示每周二,周三执行。 |
| timezone_id | String | body | true | 时区 ID。 |
executor_property 说明
| 参数名 | 类型 | 参数位置 | 是否必填 | 说明 |
|---|---|---|---|---|
| $function_code | String | body | false | 指令 code。当 action_executor 是 dpIssue 或 deviceGroupDpIssue 时,此参数必填。此参数是一个变量,具体name应该为标准指令code,例如switch_1,value值为标准指令值,例如true。 |
| hours | Integer | body | false | 延时时间,单位为小时。当 action_executor 是 delay 时,此参数必填。 |
| minutes | Integer | body | false | 延时时间,单位为分钟。当 action_executor 是 delay 时,此参数必填。 |
| seconds | Integer | body | false | 延时时间,单位为秒。当 action_executor 是 delay 时,此参数必填。 |
| 参数名 | 类型 | 说明 |
|---|---|---|
| result | String | 返回结果自动化 ID 。 |
POST: /v1.0/homes/242****/automations
{
"conditions": [
{
"display": {
"code": "switch_1",
"operator": "==",
"value": true,
"time": "14:00",
"timezone_id": "Asia/Shanghai"
},
"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/bedr***.png",
"match_type": 1,
"name": "测试自动化"
}
{
"tid": "2c1fc5cf7f4511ee82774ab24801****",
"result": "ALAuMez3r2JM****",
"t": 1699564556521,
"success": true
}
参考 错误码。
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈