自动化管理

更新时间:2023-10-09 01:57:20下载pdf

API 列表

action 描述
automation.add 添加自动化
automation.edit 修改自动化
automation.delete 删除自动化
automation.listByHome 查询家庭下的自动化列表
automation.info 查询家庭下的某个自动化
automation.conditionsTrigger 触发家庭下某个自动化的外部条件
automation.devicesByHome 查询家庭下支持自动化的设备列表
automation.weatherConditions 查询自动化支持的天气条件
automation.linkageByHome 获取家庭支持的联动条件
automation.linkageByDevice 获取设备支持的联动条件
automation.enable 启用自动化
automation.disable 停用自动化

添加自动化

接口说明

给某个家庭下添加自动化

接口地址

action: automation.add

params 请求参数

参数名 类型 说明 是否必填
home_id Long 用户家庭 ID
name String 自动化名称
background String 背景图片
conditions List 条件列表
preconditions List 前置条件,优先级最高
actions List 动作列表
match_type Integer 匹配类型:
  • 1:任意条件满足触发
  • 2:全部条件满足触发
  • 3:自定义条件触发,需设定相关逻辑运算参数 condition_rule
  • condition_rule String 自定义条件规则,当匹配类型 match_type=3,该参数必传。自定义条件规则遵从与或运算公式。每个自动化条件以其 order_num 为标识码
    例如,order_num 依次为 123,业务场景为条件 12 同时满足,或者条件 3 满足的情况下会触发自动化,则表达式为:1&&2||3

    conditions 说明

    参数名 类型 说明 是否必填
    entity_type Integer 条件类型,目前支持设备状态条件 entity_type=1,外部条件 entity_type=15,天气条件 entityType=3,定时条件 entity_type=6
    entity_id String 执行动作实体,当 entity_type=1 时,即设备 ID,必传。当 entity_type=15 时,不传,由系统自动生成。当 entityType=3,值为对应城市的 ID。当 entity_type=6 时,值固定为 timer
    display JSON 条件展示
    order_num Integer 条件排序,从 1 开始

    设备状态条件 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(关于如何获取所有 key,详见接口 查询自动化支持的天气条件
    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 条件展示

    前置条件 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 说明

    • 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

    请求示例

    {
      "action": "automation.add",
      "params": {
        "home_id": 2422120,
        "name":"测试自动化",
        "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
        "conditions":[
          {
            "display":{
              "code":"switch_1",
              "operator":"==",
              "value":true
            },
            "entity_id":"vdevo158389535209173",
            "entity_type":1,
            "order_num":1
          }
        ],
        "actions":[
          {
            "action_executor":"dpIssue",
            "entity_id":"vdevo158348104789998",
            "executor_property":{
              "switch": true
            }
          }
        ],
        "match_type":1,
      }
    }
    

    前置条件示例

    {
        "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":"vdevo157259825422309",
                "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 Integer 响应码
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result String 自动化 ID

    响应成功示例

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

    响应失败示例

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

    code 的数据类型和操作符的映射说明:

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

    修改自动化

    接口说明

    修改某个家庭下的自动化。

    接口地址

    action: automation.edit
    

    params 请求参数

    参数名 类型 说明 是否必填
    home_id Long 用户家庭 ID
    automation_id String 自动化 ID
    name String 自动化名称
    background String 背景图片
    conditions List 条件列表
    preconditions List 前置条件,优先级最高
    actions List 动作列表
    match_type Integer 匹配类型:
  • 1:任意条件满足触发
  • 2:全部条件满足触发
  • 3:自定义条件触发,需设定相关逻辑运算参数 condition_rule
  • condition_rule String 自定义条件规则,当匹配类型 match_type=3,该参数必传。自定义条件规则遵从与或运算公式。每个自动化条件以其 order_num 为标识码
    例如,order_num 依次为 123,业务场景为条件 12 同时满足,或者条件 3 满足的情况下会触发自动化,则表达式为:1&&2||3

    conditions 说明

    参数名 类型 说明 是否必填
    entity_type Integer 条件类型,目前支持设备状态条件 entity_type=1,外部条件 entity_type=15,天气条件 entityType=3,定时条件 `entity_type=6``
    entity_id String 执行动作实体,当 entity_type=1 时,即设备 ID,必传。当 entity_type=15 时,不传,由系统自动生成。当 entityType=3,值为对应城市的 ID。当 entity_type=6 时,值固定为 timer
    display JSON 条件展示
    order_num Integer 条件排序,从 1 开始

    设备状态条件 display 说明

    参数名 类型 说明 是否必填
    code String 设备的 statusCode
    operator String 操作符(详见 code 的数据类型和操作符的映射说明
    value String code 的取值

    外部条件 display 说明

    参数名 类型 说明 是否必填
    code String 外部条件的 key
    operator String 操作符(详见 code 的数据类型和操作符的映射说明
    value String 外部条件的 key 对应 code 的取值

    天气条件 display 说明

    参数名 类型 说明 是否必填
    code String 天气条件对应的 key,比如温度 temp
    operator String 操作符(详见 code 的数据类型和操作符的映射说明
    value Object 天气条件对应的 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 条件展示

    前置条件 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 说明

    • 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

    请求示例

    {
      "action": "automation.edit",
      "params": {
        "home_id": 2422120,
        "automation_id": "53IYSXI3gEn2w3Oc",
        "name":"测试自动化",
        "background":"https://images.tuyacn.com/smart/rule/cover/bedroom.png",
        "conditions":[
          {
            "display":{
              "code":"switch_1",
              "operator":"==",
              "value":true
            },
            "entity_id":"vdevo158389535209173",
            "entity_type":1,
            "order_num":1
          }
        ],
        "actions":[
          {
            "action_executor":"dpIssue",
            "entity_id":"vdevo158348104789998",
            "executor_property":{
              "switch": true
            }
          }
        ],
        "match_type":1,
      }
    }
    

    前置条件示例

    {
        "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":"vdevo157259825422309",
                "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 Integer 响应码
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result Boolean 修改成功,则返回 true

    响应成功示例

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

    响应失败示例

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

    code 的数据类型和操作符的映射说明:

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

    删除自动化

    接口说明

    删除某个家庭下的自动化。

    接口地址

    action: automation.delete
    

    params 请求参数

    参数名 类型 说明 是否必填
    home_id Long 用户家庭 ID
    automation_id String 自动化 id

    请求示例

    {
      "action": "automation.delete",
      "params": {
        "home_id": 2422120,
        "automation_id": "53IYSXI3gEn2w3Oc"
      }
    }
    

    响应参数

    参数名 类型 说明
    code Integer 响应码
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result Boolean 自动化删除成功,返回 true

    响应成功示例

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

    响应失败示例

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

    查询家庭下的自动化列表

    接口说明

    查询家庭下的自动化列表。

    接口地址

    action: automation.listByHome
    

    params 请求参数

    参数名 类型 说明 是否必填
    home_id Long 用户家庭 ID

    请求示例

    {
      "action": "automation.listByHome",
      "params": {
        "home_id": 2422120
      }
    }
    

    响应参数

    参数名 类型 说明
    code Integer 响应码
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result List 返回结果说明

    result 说明

    参数名 类型 说明
    automation_id String 自动化 id
    name String 自动化名称
    background String 背景图片
    conditions List 条件列表
    actions List 动作列表
    match_type Integer 匹配类型:
  • 1:任意条件满足触发
  • 2:全部条件满足触发
  • conditions 说明

    参数名 类型 说明 是否必填
    entity_type Integer 条件类型,目前只支持 entity_type=1
    entity_id String 执行动作实体,当前支持:设备,即设备 ID
    display JSON 条件展示,目前只支持 entity_type=1
    order_num Integer 条件排序,从 1 开始

    display 说明

    参数名 类型 说明 是否必填
    code String 设备的 statusCode
    operator String 操作符(详见 code 的数据类型和操作符的映射说明
    value String code 的取值

    actions 说明

    参数名 类型 说明 是否必填
    entity_id String 执行动作实体,当前支持:设备,即设备 ID
    executor_property JSON 执行动作参数
    action_executor String 执行动作类别,当前支持:dpIssue

    响应成功示例

    {
        "result":[
            {
                "actions":[
                    {
                        "action_executor":"dpIssue",
                        "entity_id":"vdevo157259825422309",
                        "executor_property":{
                            "switch_1":true
                        }
                    }
                ],
                "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
                    }
                ],
                "match_type":1,
                "name":"测试自动化"
            },
            {
                "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
                    }
                ],
                "match_type":1,
                "name":"自动化测试 1"
            }
        ],
        "success":true,
        "t":1572936751228
    }
    

    响应失败示例

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

    code 的数据类型和操作符的映射说明:

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

    查询家庭下的某个自动化

    接口说明

    查询家庭下的某个自动化

    接口地址

    action: automation.info
    

    params 请求参数

    参数名 类型 说明 是否必填
    home_id Long 用户家庭 ID
    automation_id String 自动化 ID

    请求示例

    {
      "action": "automation.info",
      "params": {
        "home_id": 2422120,
        "automation_id":"L07BQVabdqwFPT9K"
      }
    }
    

    响应参数

    参数名 类型 说明
    code Integer 响应码
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result List 返回结果说明

    result 说明

    参数名 类型 说明
    automation_id String 自动化 ID
    name String 自动化名称
    background String 背景图片
    conditions List 条件列表
    actions List 动作列表
    match_type Integer 匹配类型:
  • 1:任意条件满足触发
  • 2:全部条件满足触发
  • conditions 说明

    参数名 类型 说明 是否必填
    entity_type Integer 条件类型,目前只支持 entity_type=1
    entity_id String 执行动作实体,当前支持:设备,即设备 ID
    display JSON 条件展示,目前只支持 entity_type=1
    order_num Integer 条件排序,从 1 开始

    display 说明

    参数名 类型 说明 是否必填
    code String 设备的 statusCode
    operator String 操作符(详见 code 的数据类型和操作符的映射说明
    value String code 的取值

    actions 说明

    参数名 类型 说明 是否必填
    entity_id String 执行动作实体,当前支持:设备,即设备 ID
    executor_property JSON 执行动作参数
    action_executor String 执行动作类别,当前支持:dpIssue

    响应成功示例

    {
        "result":[
            {
                "actions":[
                    {
                        "action_executor":"dpIssue",
                        "entity_id":"vdevo157259825422309",
                        "executor_property":{
                            "switch_1":true
                        }
                    }
                ],
                "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
                    }
                ],
                "match_type":1,
                "name":"测试自动化"
            },
            {
                "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
                    }
                ],
                "match_type":1,
                "name":"自动化测试 1"
            }
        ],
        "success":true,
        "t":1572936751228
    }
    

    响应失败示例

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

    code 的数据类型和操作符的映射说明:

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

    触发自动化外部条件

    接口说明

    触发家庭下某个自动化的外部条件。

    接口地址

    action: automation.conditionsTrigger
    

    params 请求参数

    参数名 类型 说明 是否必填
    home_id Long 用户家庭 ID
    automation_id String 自动化 ID
    conditions List 条件列表

    conditions 说明

    参数名 类型 说明 是否必填
    entity_id String 外部条件对应 ID
    display JSON 条件

    display 说明

    参数名 类型 说明 是否必填
    code String 设备的 statusCode
    value String code 的取值

    请求示例

    {
      "action": "automation.conditionsTrigger",
      "params": {
        "home_id": 2422120,
        "automation_id": "53IYSXI3gEn2w3Oc",
        "conditions": [
        {
            "entity_id": "c9a5a524-d973-4b59-9390-0dcda0f172ec",
            "display": {
                "code":"test",
                "value":"test"
            }
        }]
      }
    }
    

    响应参数

    参数名 类型 说明
    code Integer 响应码(详情见 错误码 章节),成功时为空
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result String 触发成功,返回 true

    响应成功示例

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

    响应失败示例

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

    查询家庭下支持自动化的设备列表

    接口说明

    查询家庭下支持自动化的设备列表。

    接口地址

    action: automation.devicesByHome
    

    params 请求参数

    参数名 类型 说明 是否必填
    home_id Long 用户家庭 ID
    type String 支持的类型,值为 condition,表示支持条件。 值为 action,表示支持动作。不传时为两者之集合

    请求示例

    {
      "action": "automation.devicesByHome",
      "params": {
        "home_id": 2422120,
        "type": "condition"
      }
    }
    

    响应参数

    参数名 类型 说明
    code Integer 响应码(详情见 错误码 章节),成功时为空
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result List 返回结果说明

    result 说明

    参数名 类型 说明
    device_id String 设备编号
    uuid String 设备唯一标识
    name String 名称
    home_id String 家庭 ID
    product_id String 产品 ID

    响应成功示例

    {
        "result":[
            {
                "id":"vedo1234456",
                "uuid":"asdfghnbvcxwert",
            "name":"测试设备",
                "product_id":"r4567543dvbn",
                "home_id":"2422120"
            }
        ],
        "success":true,
        "t":1572936751228
    }
    
    

    响应失败示例

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

    查询自动化支持的天气条件

    接口说明

    查询自动化支持的天气条件。

    接口地址

    action: automation.weatherConditions
    

    params 请求参数

    请求示例

    {
      "action": "automation.weatherConditions"
    }
    

    响应参数

    参数名 类型 说明
    code Integer 响应码(详情见 错误码 章节),成功时为空
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result List 返回结果说明

    result 说明

    参数名 类型 说明
    category String 类别
    category_name String 类别名称
    operators String 操作符
    property JSON 类别属性

    响应成功示例

    {
        "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 获取联动条件或执行动作的标准功能点。

    接口地址

    action: automation.linkageByHome
    

    params 请求参数

    参数名 类型 说明 是否必填
    home_id String 家庭 ID

    请求示例

    {
      "action": "automation.linkageByHome",
      "params": {
        "home_id": 2422120
      }
    }
    

    响应参数

    参数名 类型 说明
    code Integer 响应码
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result List 返回结果说明

    result 说明

    参数名 类型 说明
    device_id String 自动化 ID
    functions List 标准指令 code,可用于动作执行
    status List 标准状态 code,可用于条件触发

    functions 说明

    参数名 类型 说明
    code String 标准下发指令 code
    name String code 名称
    type String 下发数据类型,目前支持三种类型(BooleanIntegerEnum
    values JSON code 对应的取值范围

    status 说明

    参数名 类型 说明
    code String 标准上报状态 code
    name String code 名称
    type String 上报数据类型,目前支持三种类型(BooleanIntegerEnum
    values JSON code 对应的取值范围

    响应成功示例

    {
        "success": true,
        "t": 1541072348540,
        "result": [
                    {
                      "device_id": "0120090568c63a89cb34",
                      "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 获取联动条件或执行动作的标准功能点

    接口地址

    action: automation.linkageByDevice
    

    params 请求参数

    参数名 类型 说明 是否必填
    device_id String 设备 ID

    请求示例

    {
      "action": "automation.linkageByDevice",
      "params": {
        "device_id": "vdevo158348104789998"
      }
    }
    

    响应参数

    参数名 类型 说明
    code Integer 响应码
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result Object 返回结果说明

    result 说明

    参数名 类型 说明
    device_id String 设备 ID
    functions List 标准指令 code,可用于动作执行
    status List 标准状态 code,可用于条件触发

    functions 说明

    参数名 类型 说明
    code String 标准下发指令 code
    name String code 名称
    type String 下发数据类型,目前支持三种类型(BooleanIntegerEnum
    values JSON code 对应的取值范围

    status 说明

    参数名 类型 说明
    code String 标准上报状态 code
    name String code 名称
    type String 上报数据类型,目前支持三种类型(BooleanIntegerEnum
    values JSON code 对应的取值范围

    响应成功示例

    {
        "success": true,
        "t": 1541072348540,
        "result": {
                      "device_id": "0120090568c63a89cb34",
                      "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
    }
    

    启用自动化

    接口说明

    启用自动化

    接口地址

    action: automation.enable
    

    params 请求参数

    参数名 类型 说明 是否必填
    home_id Long 家庭 ID
    automation_id String 自动化 ID

    返回参数

    参数名 类型 说明
    code Integer 响应码(详情见 错误码 章节),成功时为空
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result Boolean 返回结果

    请求示例

    {
      "action": "automation.enable",
      "params": {
        "home_id": 2422120,
        "automation_id": "53IYSXI3gEn2w3Oc"
      }
    }
    

    响应示例

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

    错误码

    以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。

    错误码 说明
    500 系统错误

    停用自动化

    接口说明

    停用自动化

    接口地址

    action: automation.disable
    

    请求参数

    参数名 类型 说明 是否必填
    home_id Long 家庭 ID
    automation_id String 自动化 ID

    返回参数:

    参数名 类型 说明
    code Integer 响应码(详情见 错误码 章节),成功时为空
    success Boolean 是否成功:
  • true:成功
  • false:失败
  • msg String 请求失败的信息,成功时为空
    t Long 返回时间戳,13 位
    result Boolean 返回结果

    请求示例

    {
      "action": "automation.disable",
      "params": {
        "home_id": 2422120,
        "automation_id": "53IYSXI3gEn2w3Oc"
      }
    }
    

    响应示例

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

    错误码

    以下为该接口常见的业务异常,更多的异常错误,请参见全局错误码。

    错误码 说明
    500 系统错误