Skip to content

群组

分组又称为群组,注意和目录的区别。分组的功能是用于群控,可以结合场景实现批量控制,分组下的所有设备都必须属于同一种产品,也就是mid要相同。一个用户最多只能建立10个群组。

创建群组

创建新的群组

curl -v -X POST \
    -H "Authorization: Bearer {JWT_TOKEN}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    "https://user-openapi.hekr.me/group" \
    -d '
      {
          "groupName": "走廊灯组",
          "deviceList" : [
            // 至少有一个设备
            {
              "devTid":"ESP_X01",
              "ctrlKey": "xxxx"
            },
            {
              "devTid":"ESP_X02",
              "ctrlKey": "yyyy"
              }
          ]
          "desc" : "xxxx"
      }
    '

参数

参数名 是否可选 参数类型 取值范围 说明
groupName 必选 String 长度[1,128] 群组名称
deviceList 必选 List 列表长度[1,512] 创建群组里含有的设备名称列表,至少需要一个设备
devTid 必选 String 设备唯一ID
ctrlKey 必选 String 设备控制码
desc 必选 String 长度[1, 128] 群组描述

返回

> 201
> {
      "groupName": "走廊灯",
      "groupId" : "xxxxx",
      "deviceList" : [
        {
          "devTid":"ESP_X01",
          "ctrlKey": "xxxx"
        },
        {
          "devTid":"ESP_X02",
          "ctrlKey": "yyyy"
          }
      ],
      "desc" : "xxxx",
      "createTime": 1462347208990,
      "updateTime": null,
      "groupMid": "01d838"
  }

列举群组

curl -v -X GET \
    -H "Authorization: Bearer {JWT_TOKEN}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    "https://user-openapi.hekr.me/group?groupId=xxx"

参数

参数名 是否可选 参数类型 取值范围 说明
groupId 可选 String 长度[1,128] 群组ID

返回

> 200
> [
    {
      "groupName": "走廊灯小组",
      "groupId" : "xxxxx",
      "deviceList" : [
        {
          "devTid":"ESP_X01",
          "ctrlKey": "xxxx"
        },
        {
          "devTid":"ESP_X02",
          "ctrlKey": "yyyy"
          }
      ],
      "desc" : "xxxx",
      "createTime" : 14xxxx,
      "updateTime" : 14xxxx,
      "groupMid": "01db28"
    }, ...
  ]

群组改名

curl -v -X PUT \
    -H "Authorization: Bearer {JWT_TOKEN}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    "https://user-openapi.hekr.me/group/{groupId}" \
    -d '{
      "newGroupName" : "新的组名"
      }'
参数

参数名 是否可选 参数类型 取值范围 说明
groupId 必选 String 群组ID
newGroupName 必选 String 长度[1,128] 群组新的名称

返回

< 204
< No Content

删除群组

curl -v -X DELETE \
    -H "Authorization: Bearer {JWT_TOKEN}" \
    -H "Content-Type: application/json " \
    -H "Accept: application/json" \
    "https://user-openapi.hekr.me/group?groupId=xxx"

参数

参数名 是否可选 参数类型 取值范围 说明
groupId 必选 String 群组ID

返回

< 204
< No Content

增加设备到群组

curl -v -X POST \
    -H "Authorization: Bearer {JWT_TOKEN}" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    "https://user-openapi.hekr.me/group/{groupId}" \
    -d '[
          // 添加多个
          {
            "ctrlKey": "704973e8d3a34dcc",
            "devTid": "jwpbghi"
          },
          ...
      ]'
参数

参数名 是否可选 参数类型 取值范围 说明
groupId 必选 String 群组ID
devTid 必选 String 设备唯一ID
ctrlKey 必选 String 设备控制码

返回

< 201
< no content

将设备从群组中删除

curl -v -X DELETE \
    -H "Authorization: Bearer {JWT_TOKEN}" \
    -H "Content-Type: application/json " \
    -H "Accept: application/json" \
    "https://user-openapi.hekr.me/group/{groupId}"
    -d '[
       // 支持删除多个
      {
        "ctrlKey" : "xxxx",
        "devTid" : "xxx"
      },
      ...
    ]'

参数

参数名 是否可选 参数类型 取值范围 说明
groupId 必选 String 群组ID
devTid 必选 String 设备唯一ID
ctrlKey 必选 String 设备控制码

返回

< 204
< No Content

错误码表

错误码 提示信息 中文释义 可能造成的原因
5200000, 620000 Success 成功
5400000 Error 未知错误 该行下面的以5400、6400开头的错误码需要单独处理
5400002 App repeat login error app重复登录 同一个appTid的app重复登录
5400003 appTid can not be empty appTid不能为空 appTid不能为空
5400004 Authorization already exists 授权关系已存在 授权关系已存在
5400005 Authorization does not exist 授权关系不存在 授权关系不存在
5400006 Bind failed due to network error 因网络原因绑定失败 因网络原因绑定失败
5400007 Bind failed due to timeout error 因超时原因绑定失败 因超时原因绑定失败
5400008 Can not bind other manufacture's device 无法绑定其他厂商设备 非公版用户无法绑定非该pid设备
5400009 Modified user profile failed 修改用户档案失败 修改用户档案失败
5400010 Check verify code error 校验code失败 校验code失败
5400011 You have reached your device's authorization limits 设备授权次数达到上限 设备授权次数达到上限,无法再次授权
5400012 Bind failed due to internal error 因内部错误绑定失败 因内部错误绑定失败,一般是因为bindKey不对或者是devTid不对
5400013 Bind failed due to repeat bind 因重复绑定绑定失败 因重复绑定绑定失败
5400014 Device does not belong to user 设备不属于用户 设备不再属于该用户
5400015 No such instruction error 没有这样的指令 没有这样的指令
5400016 Device can not repeat login 设备无法重复登录 设备无法同时登录
5400017 devTid can not be empty devTid不能为空 devTid不能为空
5400018 Create timer task failed due to counts reach limit 创建定时预约次数达到上限 创建定时预约次数达到上限
5400019 Instruction expired 授权的指令已过期 授权的指令已过期
5400020 Instruction not support 不支持该指令 不支持该指令,可能是指令填错了
5400021 Invalid email token 不合法的邮件token 不合法的邮件token
5400022 Invalid old password 不合法的旧密码 不合法的旧密码
5400023 Invalid verify code 不合法的校验code 不合法的校验code
5400024 Device does not found due to internal error, please reconnect 由于内部错误设备无法找到,请重连
5400025 No such manufacture id 不存在该pid 不存在该pid
5400026 No permission to access the instruction 没有对该指令的权限 没有对该指令的权限
5400027 Template with given id does not exist 指定模板不存在 指定模板不存在
5400028 Device does not found due to incorrect status 由于内部不正确的状态导致设备无法被找到
5400035 TaskId does not exist 指定任务不存在 指定任务不存在
5400036 Can not create duplicate template 无法创建重复模板 无法创建重复模板
5400037 devTid not match 设备id 不匹配 报文填写的devTid与登录设备的devTid不一致
5400039 User does not exist 用户不存在 用户不存在
5400045 短码或者短码密码错误
5400046 短码不足(系统错误)
5400047 无权修改其他用户绑定设备
5400043 Device can not force bind 设备无法强制绑定 设备无法强制绑定
5500000 Internal error 内部错误 内部服务错误
6400001 Reverse auth template with given id does not exist 指定id的反向注册申请不存在 请求已经被同意或拒绝
6400002 Invalid reverse authorization request 不合法的反向授权请求 设备此时已经不属于该授权者;调用者不是授权者;反向授权请求id错误
6400003 Only owner can authorize 只有属主可以授权设备给其他人 非属主尝试授权设备给其他人
6400004 Device with given devTid does not exist 指定devTid的设备不存在 操作不存在的设备
6400005 Reached the maximum number of device the folder can hold 达到文件夹所能容纳设备数量的上限 达到文件夹所能容纳设备数量的上限
6400006 Can not create duplicate template folder 无法创建同名文件夹 创建同名文件夹
6400007 Folder with given id does not exist 指定id的文件夹不存在 操作不存在的文件夹
6400008 Reached the maximum number of folder the user can create 达到创建文件夹数量上限 达到创建文件夹数量上限
6400009 Can not remove root folder 无法删除根目录 删除根目录
6400010 Can not rename root folder 无法给根目录改名 给根目录改名
6400011 Rule with given id does not exist 指定的规则不存在 操作不存在的规则
6400012 Scheduler task with given id does not exist 指定的定时预约任务不存在 操作不存在的定时预约任务
6400013 Can not create duplicate rule 无法创建相同的规则 创建相同的规则
6400014 Can not create duplicate scheduler task 无法创建相同的定时预约 创建相同的定时预约
6400015 Invalid prodPubKey 不合法的产品公共秘钥 不合法的产品公共秘钥
6400016 Has no privilege do that 没有权限这样做 操作没有权限
6400017 Invalid Param {0} 参数错误 请求参数错误
6400018 Cloud storage file with given name does not exist 指定的网盘文件不存在 操作不存在的网盘文件
6400020 Can not find this infrared code 找不到这个红外码 操作不存在的红外码
6400021 Infrared code request without response 红外服务请求出错
6400022 Can not find instruction set 无法找到指令集 操作不存在的指令集
6400023 Request params not supported 参数不支持 请求参数错误
6400024 Translating Json to String failure 解析json失败
6400025 Scheduler not supported 不支持定时预约 该设备不支持定时预约功能
6500001 Delete cloud storage file failed 删除网盘文件失败 网盘操作失败
6500002 Upload cloud storage file failed 上传网盘文件失败 网盘操作失败
6500003 Server use httpClient invoke failed http网络调用失败 http调用失败