有奖捉虫:办公协同&微信生态&物联网文档专题 HOT

1. 接口描述

接口请求域名: iot.cloud.tencent.com/api/exploreropen/appapi。 本接口(AppCreateAutomation)用于创建自动智能联动。

2. 输入参数

名称
类型
必选
描述
AccessToken
String
公共参数,用户通过微信号、手机或邮箱账号登录成功后,获取的访问 Token。
RequestId
String
公共参数,唯一请求 ID,可自行生成,推荐使用 uuid。定位问题时,需提供该次请求的 RequestId。
Action
String
公共参数,本接口取值:AppCreateAutomation。
FamilyId
String
自动智能联动所属家庭 ID。
Icon
String
自动智能联动的背景图片地址。
Name
String
自动智能联动的名称。
Status
int
自动智能联动开关状态。
0:关闭。
1:启用。
MatchType
int
条件匹配类型。
0:全部条件满足。
1:其中一个条件满足。
Conditions
Array of Condition
自动智能联动触发条件。
Actions
Array of Action
自动智能联动动作列表。
EffectiveBeginTime
String
生效开始时间。
EffectiveEndTime
String
生效结束时间。
EffectiveDays
String
生效日期由0和1组成的7位数字,0表示不执行,1表示执行,第1位为周日,依次表示周一至周六。

3. 输出参数

名称
类型
描述
RequestId
String
公共参数,唯一请求 ID,与入参相同,定位问题时,需提供该次请求的 RequestId。
AutomationId
String
自动智能联动 ID。

4. 示例

输入示例
POST https://iot.cloud.tencent.com/api/exploreropen/tokenapi HTTP/1.1
content-type: application/json
{
"RequestId": "req_1",
"Action": "AppCreateAutomation",
"FamilyId": "f_9****c1",
"Icon": "https://www.icon.com/",
"Name": "autoName",
"Status": 0, //联动的开关 0:关闭 1:启用
"MatchType": 1, //条件匹配类型 0:条件全部与 1:条件全部或
"EffectiveBeginTime": "00:00", // 【两个新增参数,用来表示开始和结束时间】
"EffectiveEndTime": "23:59",
"EffectiveDays": "1111111", // 由0和1组成的7位数字,0表示不执行,1表示执行,第1位为周日,依次表示周一至周六
"Conditions": [
{
"CondId": "abc", //条件ID,保证在一个联动下唯一即可
"CondType": 0, //条件类型 0:设备属性值条件 1:定时条件
"Property": {
"ProductId": "N****4",
"DeviceName": "g***ev",
"AliasName": "devName",
"IconUrl": "productIcon",
"PropertyId": "switch", //设备的属性Id
"Op": "eq", //条件操作符 eq 等于 ne 不等于 gt 大于 lt 小于 ge 大等于 le 小等于
"Value": 1 //比较的值
}
},
{
"CondId": "efg",
"CondType": 1,
"Timer": {
"Days": "1000000", // 由0和1组成的7位数字,0表示不执行,1表示执行,第1位为周日,依次表示周一至周六
"TimePoint": "09:30" // 触发时间,24小时制,例如"14:00"
}
}
],
"Actions": [
{
"ActionType": 0, // 0: 则为设备动作,具体参数设置为Data 0 :设备动作 1:延时 2:场景 3:通知
"ProductId": "R32***0EU",
"DeviceName": "df***yY",
"Data": "{\\"brightness\\": 25}", // ActionType为 0 :设备动作参数 为1:延时时间单位秒 2:执行场景Id 3:通知内容
"AliasName": "12345",
"IconUrl": "url"
},
{
"ActionType": 1, //1: 则为延时动作,具体延时时间为Data,值为秒
"Data": "100"
}
],
"AccessToken": "***v2"
}

输出示例: 成功
{
"Response": {
"AutomationId": "a_cd61dd*****d21d6aeffea",
"RequestId": "req_1"
}
}

5. 错误码

错误码
描述
InternalError
内部错误。
InternalError.InternalServerExceptionDB
DB 错误。
InvalidParameterValue
参数取值错误。
InvalidParameterValue.InvalidAccessToken
Token 无效。
InvalidParameterValue.NoPermission
用户对该设备无权限。
LimitExceeded
数量超过限制。