智能家居接口属性参考表

智能家居接口V2.0-控制接口参考表

更新时间

2017/7/24 增加状态查询和变化通知消息,增加按步长调节频道

2017/8/3 增加设备发现响应说明
调整返回属性格式

2017/8/4 补充上一首消息

2017/8/18 增加风速和固定目标温度接口

2017/8/26 补充设备发现,模式,风速说明。

2017/8/26 增加动作控制。

2017/10/27 增加文本控制并增加设备发现标签。

2018/03/02 增加增加色温控制和自定义面板控制。

2018/03/27 增加批量查询设备在线状态的接口(暂时未开放)。

2018/04/10 增加透传控制接口。

详细接口参考表

以下控制查询相关接口,首先需要设备支持,设备意图下发或部署。

各消息的详细属性参数请参考 智能家居接口属性参考表

设备发现

接口名称: DNA.Discovery

  {
      "directive": {
          "header": {
              "namespace": "DNA.Discovery",
              "name": "Discover",
              "interfaceVersion": "2",
              "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
          },
          "payload": {
              "scope": {
                  "type": "BearerToken",
                  "token": "some-access-token",
              },
              "options": {
                  "enableIntent": false,
                  "additionals":{
                      
                  }
              }
          }
      }
  }

-ToB技能发现设备发现请求(预发布)

  {
      "directive": {
          "header": {
              "namespace": "DNA.Discovery",
              "name": "Discover",
              "interfaceVersion": "2",
              "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
          },
          "payload": {
              "scope": {
                  "type": "BearerTokenWithPartition",
                  "token": "some-access-token",
  	  "mtag":""
              },
              "options": {
                  "enableIntent": false,
                  "additionals":{
                      
                  }
              }
          }
      }
  }

-根据某个设备发现用户设备列表(预发布)

  {
      "directive": {
          "header": {
              "namespace": "DNA.Discovery",
              "name": "Discover",
              "interfaceVersion": "2",
              "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
          },
          "payload": {
              "scope": {
                  "type": "InnerDid",
  	  			"endpointid":"one dev endpointid "
              },
              "options": {
                  "enableIntent": false,
                  "additionals":{
                      
                  }
              }
          }
      }
  }

其中options字段,可以用来指示设备发现时对设备列表等做特别处理。enableIntent只有要使用DNA.TextControl接口时才需要设置为true。

additionals字段可以填入更多内容,对设备列表的返回进行过滤和限制,具体参考其他文档(由于这部分业务暂未上线,该字段填空即可)。

  {
      "context": {},
      "event": {
          "header": {
              "namespace": "DNA.Discovery",
              "name": "Response",
              "interfaceVersion": "2",
              "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4"
          },
          "payload": {
          },
          "scenes": [{
              "sceneId":"",
              "friendlyName":"",
              "manufacturerName": "Sample Manufacturer",
              "description":"",
              "displayCategories":["SCENE_TRIGGER"],
              "cookie":{},
              "capabilities":[
                  {
                      "type":"DNAInterface",
                      "interface":"DNA.SceneControl",
                      "version":"2",
                      "supportsDeactivation":false,
                      "proactivelyReported":true
                  }
              ]
          }],
          "endpoints": [
              {
                  "endpointId": "appliance-001",
                  "parentId":"",//空代表普通设备或网关设备
                  "friendlyName": "智能遥控",
                  "isReachable":true,
                  "description": "由BroadLink生产的智能遥控",
                  "manufacturerName": "Sample Manufacturer",
                  "icon":"产品图片URL",
                  "brand":"品牌",
                  "displayCategories": [
                      "TELECONTROLLER"//万能遥控品类
                  ],
                  "familyName": "用户设置的家庭名称",
                  "roomName": "用户设置的房间名称",
                  "cookie": {
                      "extraDetail1": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                      "extraDetail2": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                      "extraDetail3": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                      "extraDetail4": "某些设备可能会用到这个cookie,需要在控制时原样返回"
                  },
                  "capabilities": [
                  ]
              },
              {
                  "endpointId": "appliance-002",
                  "parentId":"appliance-001",//非空代表该设备是子设备,parentId为网关设备endpointId
                  "friendlyName": "电视面板",
                  "isReachable":true,
                  "description": "BroadLink 电视面板",
                  "manufacturerName": "Sample Manufacturer",
                  "icon":"产品图片URL",
                  "brand":"品牌",
                  "displayCategories": [
                      "TV"
                  ],
                  "familyName": "用户设置的家庭名称",
                  "roomName": "用户设置的房间名称",
                  "cookie": {
                      "extraDetail1": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                      "extraDetail2": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                      "extraDetail3": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                      "extraDetail4": "某些设备可能会用到这个cookie,需要在控制时原样返回"
                  },
                  "capabilities": [
                      {
                          "type": "DNAInterface",
                          "interface": "DNA.PowerControl",
                          "version": "2",
                          "properties": {
                              "supported": [
                                  {
                                      "name": "powerState"
                                  }
                              ],
                              "proactivelyReported": true,
                              "retrievable": true
                          },
                         "actions": {//目前未上线
                             "supported": [
                              {
                                   "name": "ChangePowerState"
                              }
                             ]
                         }
                      }
                  ]
              },
              {
                  "endpointId": "appliance-003",
                  "parentId":"",//空代表普通设备或网关设备
                  "friendlyName": "灯",
                  "isReachable":true,
                  "description": "BroadLink 灯",
                  "manufacturerName": "Sample Manufacturer",
                  "icon":"产品图片URL",
                  "brand":"品牌",
                  "displayCategories": [
                      "LIGHT",
                      "SMARTPLUG"
                  ],
                  "familyName": "用户设置的家庭名称",
                  "roomName": "用户设置的房间名称",
                  "cookie": {
                      "extraDetail1": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                      "extraDetail2": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                      "extraDetail3": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                      "extraDetail4": "某些设备可能会用到这个cookie,需要在控制时原样返回"
                  },
                  "capabilities": [
                      {
                          "type": "DNAInterface",
                          "interface": "DNA.PowerControl",
                          "version": "2",
                          "properties": {
                              "supported": [
                                  {
                                      "name": "powerState"
                                  }
                              ],
                              "proactivelyReported": true,
                              "retrievable": true
                          },
                         "actions": {//目前未上线
                             "supported": [
                              {
                                   "name": "ChangePowerState"
                              }
                             ]
                         }
                      }
                  ]
              }
          ]
      }
  }

isReachable 表示设备是否在线,在线为true,不在线为false。

capabilities字段中描述了对应设备的具体能力,包括版本,支持的属性, 是否支持主动上报,是否支持状态查询。其中interface字段是和接口名称一一对应的。

即使两个产品的品类(displayCategories)相同,具备的能力也可能不同,所以需要根据设备发现返回的

capabilities字段描述的功能动态判断,目前会返回properties和actions两个字段,推荐使用actions.

cookie字段是与一个endpoint运行时关联的字段,里面保存控制时的一些上下文信息, 服务器只要保存下来就可以了,不需要对字段里面的数据进行解析。

cookie里面的数量是不定的,可能没有,也可能有多个。

name
proactivelyReported true: 支持主动上报 false: 不支持主动上报
retrievable true: 支持状态查询 false: 不支持状态查询

设备发现返回的displayCategories可以参考 品类参考表。 对于插座设备,会同时返回插座类型和负载类型。比如[“SMARTPLUG”,“WATER_HEATER”]

批量查询设备在线状态(暂时未开放

接口名称: DNA.QueryState

isReachable字段true表示在线,false表示离线

请求例子

{
  "directive": {
    "header": {
       "namespace": "DNA.QueryState",
       "name": "QueryState",
       "interfaceVersion": "2",
       "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
    },
    "endpoints": [{
      "endpointId": "appliance-001",
      "cookie": {
                 "did":"0000000000000000000034ea3472f3df",
                 "pid":"30014"
              }
    }],
    "payload": {
        "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
      }
    }
  }
}

响应例子

{
  "context": {
    "properties": [ {
       "namespace": "DNA.QueryState",
       "name": "QueryState",
       "timeOfSample": "2017-02-03T16:20:50.52Z"
    } ]
  },
  "event": {
    "header": {
       "namespace": "DNA.QueryState",
       "name": "Response",
       "interfaceVersion": "2",
       "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4"
    },
    "endpoints": [{
      "endpointId": "0000000000000000000034ea3472f3df",
              "cookie": {
                 "did":"0000000000000000000034ea3472f3df"
              },
              "isReachable":true
    }],
    "payload": {
    }
  }
}

电源控制

控制设备的电源开关

接口名称: DNA.PowerControl

请求例子

{
  "directive": {
    "header": {
       "namespace": "DNA.PowerControl",
       "name": "ChangePowerState",
       "interfaceVersion": "2",
       "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
    },
    "endpoint": {
      "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
      },
      "endpointId": "appliance-001",
      "cookie": {}
    },
    "payload": {
        "powerState": "ON"
    }
  }
}

响应例子

{
  "context": {
    "properties": [ {
       "namespace": "DNA.PowerControl",
       "name": "powerState",
       "value": "ON",
       "timeOfSample": "2017-02-03T16:20:50.52Z",
    } ]
  },
  "event": {
    "header": {
       "namespace": "DNA.PowerControl",
       "name": "Response",
       "interfaceVersion": "2",
       "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}

频道控制

控制电视/机顶盒频道

接口名称: DNA.ChannelControl

频道号请求例子

{
  "directive": {
    "header": {
       "namespace": "DNA.ChannelControl",
       "name": "ChangeChannel",
       "interfaceVersion": "2",
       "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
    },
    "endpoint": {
      "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
      },
      "endpointId": "appliance-001",
      "cookie": {}
    },
    "payload": {
          "channelNumber":"1234"
    }
  }
}

响应例子

{
  "context": {
    "properties": [ {
       "namespace": "DNA.ChannelControl",
       "name": "channelNumber",
       "value":"123",
       "timeOfSample": "2017-02-03T16:20:50.52Z",
    } ]
  },
  "event": {
    "header": {
       "namespace": "DNA.ChannelControl",
       "name": "Response",
       "interfaceVersion": "2",
       "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}

按步长调整频道

请求:

{
  "directive": {
    "header": {
      "namespace": "DNA.ChannelControl",
      "name": "AdjustChannel",
      "messageId": "c8d53423-b49b-48ee-9181-f50acedf2870",
      "interfaceVersion": "2"
    },
   "endpoint": {
      "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
      },
      "endpointId": "appliance-001",
      "cookie": {}
    },
    "payload": {
      "channelSteps" : 1
    }
  }
}

响应:

{
  "context": {
    "properties": [
        {
           "namespace": "DNA.ChannelControl",
           "name": "channelSteps",
           "value": 1
           "timeOfSample": "2017-02-03T16:20:50.52Z",
        }
    ]
  },
  "event": {
      "header": {
      "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
      "name": "Response",
      "interfaceVersion": "2"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}

频道名称请求例子

{
  "directive": {
    "header": {
       "namespace": "DNA.ChannelControl",
       "name": "ChangeChannel",
       "interfaceVersion": "2",
       "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
    },
    "endpoint": {
      "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
      },
      "endpointId": "appliance-001",
      "cookie": {}
    },
    "payload": {
          "channelName":"浙江卫视"
    }
  }
}

响应例子

{
  "context": {
    "properties": [ {
       "namespace": "DNA.ChannelControl",
       "name": "channelNumber",
       "value":"123",
       "timeOfSample": "2017-02-03T16:20:50.52Z",
    } ]
  },
  "event": {
    "header": {
       "namespace": "DNA.ChannelControl",
       "name": "Response",
       "interfaceVersion": "2",
       "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}

音量控制

控制设备的音量

接口名称: DNA.VolumeControl

  {
    "directive": {
      "header": {
        "namespace": "DNA.VolumeControl",
        "name": "AdjustVolume",
        "messageId": "c8d53423-b49b-48ee-9181-f50acedf2870",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001",
        "cookie": {}
      },
      "payload": {
        "volumeSteps": 2
      }
    }
  }

响应

{
  "context": {
    "properties": [
        {
           "namespace": "DNA.VolumeControl",
           "name": "volumeSteps",
           "value": 20
           "timeOfSample": "2017-02-03T16:20:50.52Z",
        }
    ]
  },
  "event": {
      "header": {
      "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
      "name": "Response",
      "interfaceVersion": "2"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}
  {
    "directive": {
      "header": {
        "namespace": "DNA.VolumeControl",
        "name": "SetVolume",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<some-access-token"
        },
        "endpointId": "<appliance-001",
        "cookie": {
  
        }
      },
      "payload": {
        "volume": 50
      }
    }
  }

响应

{
  "context": {
    "properties": [
        {
           "namespace": "DNA.VolumeControl",
           "name": "volume",
           "value": 50
           "timeOfSample": "2017-02-03T16:20:50.52Z",
        }
    ]
  },
  "event": {
      "header": {
      "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
      "name": "Response",
      "interfaceVersion": "2"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}
  {
    "directive": {
      "header": {
        "namespace": "DNA.VolumeControl",
        "name": "SetMute",
        "messageId": "c8d53423-b49b-48ee-9181-f50acedf2870",
        "interfaceVersion": "3"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<some-access-token"
        },
        "endpointId": "<appliance-001",
        "cookie": {}
      },
      "payload": {
        "mute": true
      }
    }
  }

响应

{
  "context": {
    "properties": [
        {
           "namespace": "DNA.VolumeControl",
           "name": "mute",
           "value": true
           "timeOfSample": "2017-02-03T16:20:50.52Z",
        }
    ]
  },
  "event": {
      "header": {
      "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
      "name": "Response",
      "interfaceVersion": "2"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}

播放控制

控制设备的播放/暂停等,由于播放控制不涉及状态,所有返回是统一的。

接口名称:DNA.PlaybackControl

  {
    "directive": {
      "header": {
        "namespace": "DNA.PlaybackController",
        "name": "Play",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "directive": {
      "header": {
        "namespace": "DNA.PlaybackController",
        "name": "Pause",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "directive": {
      "header": {
        "namespace": "DNA.PlaybackController",
        "name": "Resume",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "directive": {
      "header": {
        "namespace": "DNA.PlaybackController",
        "name": "Next",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "directive": {
      "header": {
        "namespace": "DNA.PlaybackController",
        "name": "Previous",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "directive": {
      "header": {
        "namespace": "DNA.PlaybackController",
        "name": "FastForward",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "directive": {
      "header": {
        "namespace": "DNA.PlaybackController",
        "name": "Rewind",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "context": {
      "properties": [
      ]
    },
    "event": {
        "header": {
        "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
        "name": "Response",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001"
      },
      "payload": {
      }
    }
  }

风速控制

控制风扇的速度

接口名称:DNA.WindSpeedControl

  {
    "directive": {
      "header": {
        "namespace": "DNA.WindSpeedControl",
        "name": "SetWindSpeed",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001",
        "cookie": {}
      },
      "payload": {
        "windSpeed": "HIGH"
      }
    }
  }

响应:

{
  "context": {
    "properties": [
        {
           "namespace": "DNA.PercentageControl",
           "name": "windSpeed",
           "value":"HIGH",
           "timeOfSample": "2017-02-03T16:20:50.52Z",
        }
    ]
  },
  "event": {
      "header": {
      "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
      "name": "Response",
      "interfaceVersion": "2"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}

具体支持的风俗列表,请参考智能家居接口属性参考表

  {
    "directive": {
      "header": {
        "namespace": "DNA.WindSpeedControl",
        "name": "AdjustWindSpeed",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001",
        "cookie": {}
      },
      "payload": {
        "windSpeedSteps": 1
      }
    }
  }

响应:

{
  "context": {
    "properties": [
        {
           "namespace": "DNA.PercentageControl",
           "name": "windSpeedSteps",
           "value":1,
           "timeOfSample": "2017-02-03T16:20:50.52Z",
        }
    ]
  },
  "event": {
      "header": {
      "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
      "name": "Response",
      "interfaceVersion": "2"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}

风向控制

控制设备的风向,控制不涉及状态,所有返回是统一的。

接口名称:DNA.AirFlowControl

  {
  “directive”: {
  “header”: {
  “namespace”: “DNA.AirFlowControl”, “name”: “SetAirFlow”, “messageId”: “5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4”, “interfaceVersion”: “2”
  
  }, “endpoint”: {
  
  “scope”: {
  “type”: “BearerToken”, “token”: “<OAuth2认证后得到的access_token”
  
  }, “endpointId”: “<设备ID,发现时返回”, “cookie”: { }
  
  }, “payload”: {
  
  “airFlow”:”VerticalFlow/HorizontalFlow/StopFlow/VHFlow”
  
  }
  
  }
  
  }

其中VerticalFlow/HorizontalFlow/StopFlow/VHFlow分别代表垂直扫风,水平扫风,停止扫风,垂直水平扫风

响应

{
  "context": {
    "properties": [
    ]
  },
  "event": {
      "header": {
      "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
      "name": "Response",
      "interfaceVersion": "2"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}
  {
    "directive": {
      "header": {
        "namespace": "DNA.AirFlowControl",
        "name": "Start",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "directive": {
      "header": {
        "namespace": "DNA.AirFlowControl",
        "name": "Stop",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "directive": {
      "header": {
        "namespace": "DNA.AirFlowControl",
        "name": "HorizontalFlow",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }
  {
    "directive": {
      "header": {
        "namespace": "DNA.AirFlowControl",
        "name": "VerticalFlow",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "<OAuth2认证后得到的access_token"
        },
        "endpointId": "<设备ID,发现时返回",
        "cookie": {
        }
      },
      "payload": {
      }
    }
  }

响应:

{
  "context": {
    "properties": [
    ]
  },
  "event": {
      "header": {
      "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
      "name": "Response",
      "interfaceVersion": "2"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "some-access-token"
      },
      "endpointId": "appliance-001"
    },
    "payload": {
    }
  }
}

颜色控制(暂时不开放)

控制设备的颜色

接口名称:DNA.ColorControl

  {
      "directive": {
          "header": {
              "namespace": "DNA.ColorControl",
              "name": "SetColor",
              "interfaceVersion": "2",
              "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
          },
          "endpoint": {
              "scope": {
                  "type": "BearerToken",
                  "token": "some-access-token"
              },
              "endpointId": "appliance-001",
              "cookie": {}
          },
          "payload": {
              "color": {
                  "hue": 350.5,
                  "saturation": 0.7138,
                  "brightness": 0.6524
              }
          }
      }
  }
  {
    "context": {
      "properties": [
          {
             "namespace": "DNA.ColorControl",
             "name": "color",
             "value":{
                  "hue": 350.5,
                  "saturation": 0.7138,
                  "brightness": 0.6524
             },
             "timeOfSample": "2017-02-03T16:20:50.52Z",
          }
      ]
    },
    "event": {
        "header": {
        "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
        "name": "Response",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001"
      },
      "payload": {
      }
    }
  }

颜色名称控制

控制设备的颜色

接口名称:DNA.ColorNameControl

  {
      "directive": {
          "header": {
              "namespace": "DNA.ColorNameControl",
              "name": "SetColorName",
              "interfaceVersion": "2",
              "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
          },
          "endpoint": {
              "scope": {
                  "type": "BearerToken",
                  "token": "some-access-token"
              },
              "endpointId": "appliance-001",
              "cookie": {}
          },
          "payload": {
              "colorName": "RED"
          }
      }
  }
  {
    "context": {
      "properties": [
          {
             "namespace": "DNA.ColorNameControl",
             "name": "colorName",
             "value":"RED",
             "timeOfSample": "2017-02-03T16:20:50.52Z",
          }
      ]
    },
    "event": {
        "header": {
        "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
        "name": "Response",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001"
      },
      "payload": {
      }
    }
  }

色温控制

控制设备的色温

接口名称:DNA.ColorTempControl

  {
    "directive": {
      "header": {
        "namespace": "DNA.ColorTempControl",
        "name": "SetColorTemp",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001",
        "cookie": {}
      },
      "payload": {
        "colortemp": 3000
      }
    }
  }
  {
    "context": {
      "properties": [
          {
             "namespace": "DNA.ColorTempControl",
             "name": "colortemp",
             "value":3000,
             "timeOfSample": "2017-02-03T16:20:50.52Z",
          }
      ]
    },
    "event": {
        "header": {
        "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
        "name": "Response",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001"
      },
      "payload": {
      }
    }
  }

亮度控制

控制设备的亮度

接口名称:DNA.BrightnessControl

  {
    "directive": {
      "header": {
        "namespace": "DNA.BrightnessControl",
        "name": "SetBrightness",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001",
        "cookie": {}
      },
      "payload": {
        "brightness": 42
      }
    }
  }
  {
    "context": {
      "properties": [
          {
             "namespace": "DNA.BrightnessControl",
             "name": "brightness",
             "value":42,
             "timeOfSample": "2017-02-03T16:20:50.52Z",
          }
      ]
    },
    "event": {
        "header": {
        "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
        "name": "Response",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001"
      },
      "payload": {
      }
    }
  }

正数表示增加,负数表示减少.

  {
    "directive": {
      "header": {
        "namespace": "DNA.BrightnessControl",
        "name": "AdjustBrightness",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001",
        "cookie": {}
      },
      "payload": {
        "brightnessSteps": 42
      }
    }
  }
  {
    "context": {
      "properties": [
          {
             "namespace": "DNA.BrightnessControl",
             "name": "brightness",
             "value":42,
             "timeOfSample": "2017-02-03T16:20:50.52Z",
          }
      ]
    },
    "event": {
        "header": {
        "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
        "name": "Response",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001"
      },
      "payload": {
      }
    }
  }

百分比控制

控制设备属性的百分比

接口名称:DNA.PercentageControl

请求:

 {
   "directive": {
     "header": {
       "namespace": "DNA.PercentageControl",
       "name": "SetPercentage",
       "interfaceVersion": "2",
       "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001",
       "cookie": {}
     },
     "payload": {
       "percentage": 74
     }
   }
 }

响应:

 {
   "context": {
     "properties": [
         {
            "namespace": "DNA.PercentageControl",
            "name": "percentage",
            "value":42,
            "timeOfSample": "2017-02-03T16:20:50.52Z",
         }
     ]
   },
   "event": {
       "header": {
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "Response",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
     }
   }
 }

温控器控制

       {
         "directive": {
           "header": {
             "namespace": "DNA.ThermostatControl",
             "name": "SetFixedTargetTemperature",
             "interfaceVersion": "2",
             "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
           },
           "endpoint": {
             "scope": {
               "type": "BearerToken",
               "token": "some-access-token"
             },
             "endpointId": "appliance-001",
             "cookie": {}
           },
           "payload": {
             "fixedTargetTemperature": 23
           }
         }
       }

响应:

    {
      "context": {
        "properties": [
            {
              "namespace": "DNA.ThermostatControl",
              "name": "fixedTargetTemperature",
              "value":23,
              "timeOfSample": "2017-02-03T16:20:50.52Z",
            }
        ]
      },
      "event": {
          "header": {
          "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
          "name": "Response",
          "interfaceVersion": "2"
        },
        "endpoint": {
          "scope": {
            "type": "BearerToken",
            "token": "some-access-token"
          },
          "endpointId": "appliance-001"
        },
        "payload": {
        }
      }
    }

请求:

    {
      "directive": {
        "header": {
          "namespace": "DNA.ThermostatControl",
          "name": "AdjustFixedTargetTemperature",
          "interfaceVersion": "2",
          "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
        },
        "endpoint": {
          "scope": {
            "type": "BearerToken",
            "token": "some-access-token"
          },
          "endpointId": "appliance-001",
          "cookie": {}
        },
        "payload": {
          "fixedTargetTemperatureSteps": 1
        }
      }
    }
响应:
    {
      "context": {
        "properties": [
            {
               "namespace": "DNA.ThermostatControl",
               "name": "fixedTargetTemperatureSteps",
               "value":1,
               "timeOfSample": "2017-02-03T16:20:50.52Z",
            }
        ]
      },
      "event": {
          "header": {
          "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
          "name": "Response",
          "interfaceVersion": "2"
        },
        "endpoint": {
          "scope": {
            "type": "BearerToken",
            "token": "some-access-token"
          },
          "endpointId": "appliance-001"
        },
        "payload": {
        }
      }
    }

请求:

  {
    "directive": {
      "header": {
        "namespace": "DNA.ThermostatControl",
        "name": "SetMode",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001",
        "cookie": {}
      },
      "payload": {
        "mode": "COLD"
      }
    }
  }
  
  响应:
  {
    "context": {
      "properties": [
          {
             "namespace": "DNA.ThermostatControl",
             "name": "mode",
             "value":"COLD",
             "timeOfSample": "2017-02-03T16:20:50.52Z",
          }
      ]
    },
    "event": {
        "header": {
        "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
        "name": "Response",
        "interfaceVersion": "2"
      },
      "endpoint": {
        "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
        },
        "endpointId": "appliance-001"
      },
      "payload": {
      }
    }
  }

具体支持的模式列表,请参考智能家居接口属性参考表

温度感知

查询温度 接口名称:DNA.TemperatureSensor

 {
   "directive": {
     "header": {
       "namespace": "DNA.TemperatureSensor",
       "name": "ReportState",
       "interfaceVersion": "2",
       "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001",
       "cookie": {}
     },
     "payload": {}
   }
 }
 
 
 响应
 {
   "context": {
     "properties": [
         {
            "namespace": "DNA.TemperatureSensor",
            "name": "temperature",
            "value":{
                 "value":12,
                 "scale":"CELSIUS",
                 "attributeName":""
                 "scaleName":"",
                 "valueName":""
            },
            "timeOfSample": "2017-02-03T16:20:50.52Z"
         }
     ]
   },
   "event": {
       "header": {
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "StateReport",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
     }
   }
 }

湿度控制(预发布)

设定湿度 接口名称:DNA.HumidityControl

 {
   "directive": {
     "header": {
       "namespace": "DNA.HumidityControl",
       "name": "SetHumidity",
       "interfaceVersion": "2",
       "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001",
       "cookie": {}
     },
     "payload": {
       "humidity": 20
     }
   }
 }
 
 
 响应
 {
   "context": {
     "properties": [
         {
 
         }
     ]
   },
   "event": {
       "header": {
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "Response",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
     }
   }
 }

湿度感知

查询湿度 接口名称:DNA.HumiditySensor

 {
   "directive": {
     "header": {
       "namespace": "DNA.HumiditySensor",
       "name": "ReportState",
       "interfaceVersion": "2",
       "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001",
       "cookie": {}
     },
     "payload": {}
   }
 }
 
 
 响应
 {
   "context": {
     "properties": [
         {
            "namespace": "DNA.HumiditySensor",
            "name": "humidity",
            "value":{
                 "value":12,
                 "scale":"",
                 "attributeName":""
                 "scaleName":"",
                 "valueName":""
            },
            "timeOfSample": "2017-02-03T16:20:50.52Z",
         }
     ]
   },
   "event": {
       "header": {
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "StateReport",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
     }
   }
 }

PM2.5感知

查询PM2.5 接口名称:DNA.PM2_5Sensor

 {
   "directive": {
     "header": {
       "namespace": "DNA.PM2_5Sensor",
       "name": "ReportState",
       "interfaceVersion": "2",
       "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001",
       "cookie": {}
     },
     "payload": {}
   }
 }
 
 
 响应
 {
   "context": {
     "properties": [
         {
            "namespace": "DNA.PM2_5Sensor",
            "name": "pm2_5",
            "value":{
                 "value":20,
                 "scale":"",
                 "attributeName":""
                 "scaleName":"",
                 "valueName":""
            },
            "timeOfSample": "2017-02-03T16:20:50.52Z",
         }
     ]
   },
   "event": {
       "header": {
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "StateReport",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
     }
   }
 }

状态查询

 请求
 
 {
   "directive": {
     "header": {
       "messageId": "abc-123-def-456",
       "namespace": "DNA.TemperatureSensor"|“DNA”,
       "name": "ReportState",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "endpointId": "appliance-001",
       "cookie": {},
       "scope":{
             "type":"BearerToken",
             "token":"some-access-token"
       }
     },
     "payload": {
     }
   }
 }
 响应:
 
 {
   "context": {
     "properties": [
         {
            "namespace": "DNA.TemperatureSensor",
            "name": "temperature",
            "value":{
                 "value":12,
                 "scale":"",
                 "attributeName":""
                 "scaleName":"",
                 "valueName":""
            },
            "timeOfSample": "2017-02-03T16:20:50.52Z",
         }
     ]
   },
   "event": {
       "header": {
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "StateReport",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
     }
   }
 }

状态查询响应时,每个属性都会携带如下字段:


scale 单位
attributeName 属性名称
scaleName 单位名称
valueName 值名称

如果是查询一个endpoint的全部状态, namespace需要填DNA.

如果是查询单个属性,则填如对应属性的接口名称。

变化通知(目前只对定制产品开放)

变化通知有三种通知:

  1. 设备属性变化,比如温度,开关状态
  2. 设备附件状态变化,比如用户的设备名称变化,设备在线情况变化,用户新增加/删除设备

当一个设备多个属性变化时,放到payload中,一起上报.如果发现是设备列表发生变化,那么需要重新调用 设备发现。

上报格式:

 {
   "context": {
     "properties": []
   },
   "event": {
       "header": {
       "namespace": "DNA",
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "ChangeReport",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
       "reportType":"STATE_CHANGE",
       "change": {
         "cause": {
           "type": "PHYSICAL_INTERACTION"
         },
         "properties": [
           {
             "namespace": "DNA.PowerControl",
             "name": "powerState",
             "value": "ON",
             "timeOfSample": "2017-02-03T16:20:50.52Z",
             "uncertaintyInMilliseconds": 0
           },
           {
             "namespace": "DNA.PercentageControl",
             "name": "percentage",
             "value": 40,
             "timeOfSample": "2017-02-03T16:20:50.52Z",
           }
         ]
       }
     }
   }
 }

reportType 说明 备注
STATE_CHANGE 设备状态变化
ENDPOINT_CHANGE 设备列表变化

cause字段用来描述设备状态变化的原因,如果是设备列表变化,可 以忽略这个字段。

家庭信息变化通知接口 ​

上报格式: 响应

Header:userid,Reqaccesstoken
Body:
  {
    "context":{
      "properties":null
    },
    "event":{
      "header":{
        "namespace":"DNA",
        "name":"ChangeReport",
        "interfaceVersion":"2",
        "messageId":"roih-o4k9dud5jcr4n4pq"
      },
      "payload":{
        "reportType":"ENDPOINT_CHANGE",
        "change":{
            "cause":{
                "type":""
            }
        },
        "scenes":null,
        "endpoints":[
            {
                "endpointId":"300867042819508",
                "parentId":"",
                "friendlyName":"电视",
                "description":"BroadLink 智能遥控",
                "manufacturerName":"BroadLink",
                "icon":"https://ihcv0.ibroadlink.com/ec4appsysinfo/category2/TV.png",
                "brand":"BroadLink",
                "roomName":"客厅",
                "displayCategories":[
                    "TV"
                ],
                "cookie":{
                    "did":"0000000000000000000034ea3434ea34",
                    "pid":"10141",
                    "sdid":"",
                    "spid":"",
                    "userid":"userid1",
                    "devname":"电视",
                    "moduleid":"300867042819508",
                    "moduletype":"24",
                    "familyid":"familyid",
                    "familyname":"我的家庭"
                },
                "isReachable":true,
                "capabilities":[
                    {
                        "type":"DNAInterface",
                        "interface":"DNA.PlaybackController",
                        "version":"2",
                        "properties":{
                            "supported":null,
                            "proactivelyReported":false,
                            "retrievable":false
                        },
                        "actions":{
                            "supported":null
                        }
                    },
                    {
                        "type":"DNAInterface",
                        "interface":"DNA.PowerControl",
                        "version":"2",
                        "properties":{
                            "supported":[
                                {
                                    "name":"powerState"
                                }
                            ],
                            "proactivelyReported":false,
                            "retrievable":false
                        },
                        "actions":{
                            "supported":null
                        }
                    },
                    {
                        "type":"DNAInterface",
                        "interface":"DNA.VolumeControl",
                        "version":"2",
                        "properties":{
                            "supported":[
                                {
                                    "name":"volumeSteps"
                                },
                                {
                                    "name":"mute"
                                }
                            ],
                            "proactivelyReported":false,
                            "retrievable":false
                        },
                        "actions":{
                            "supported":null
                        }
                    },
                    {
                        "type":"DNAInterface",
                        "interface":"DNA.ChannelControl",
                        "version":"2",
                        "properties":{
                            "supported":[
                                {
                                    "name":"channelNumber"
                                },
                                {
                                    "name":"channelName"
                                },
                                {
                                    "name":"channelSteps"
                                }
                            ],
                            "proactivelyReported":false,
                            "retrievable":false
                        },
                        "actions":{
                            "supported":null
                        }
                    }
                ],
                "additional":{
                    "channellist":[
                        {
                            "name":"示例频道",
                            "extend":"12"
                        }
                    ]
                }
            },

            {
                "endpointId":"300866178209626xxxx",
                "parentId":"",
                "friendlyName":"风扇",
                "description":"BroadLink SK无叶风扇",
                "manufacturerName":"BroadLink",
                "icon":"https://ihcv0.ibroadlink.com/ec4appsysinfo/category2/FAN.png",
                "brand":"BroadLink",
                "roomName":"客厅",
                "displayCategories":[
                    "FAN"
                ],
                "cookie":{
                    "did":"0000000000000000000034ea3434ea34",
                    "pid":"1234",
                    "sdid":"00000000000000000000fe7ff734ea34",
                    "spid":"000000000000000000000000d0010100",
                    "userid":"userid1",
                    "devname":"",
                    "moduleid":"",
                    "moduletype":"",
                    "familyid":"familyid",
                    "familyname":"我的家庭"
                },
                "isReachable":true,
                "capabilities":[
                    {
                        "type":"DNAInterface",
                        "interface":"DNA.PowerControl",
                        "version":"2",
                        "properties":{
                            "supported":[
                                {
                                    "name":"powerState"
                                }
                            ],
                            "proactivelyReported":false,
                            "retrievable":false
                        },
                        "actions":{
                            "supported":null
                        }
                    },
                    {
                        "type":"DNAInterface",
                        "interface":"DNA.WindSpeedControl",
                        "version":"2",
                        "properties":{
                            "supported":[
                                {
                                    "name":"windSpeedSteps"
                                }
                            ],
                            "proactivelyReported":false,
                            "retrievable":false
                        },
                        "actions":{
                            "supported":null
                        }
                    },
                    {
                        "type":"DNAInterface",
                        "interface":"DNA.AirFlowControl",
                        "version":"2",
                        "properties":{
                            "supported":null,
                            "proactivelyReported":false,
                            "retrievable":false
                        },
                        "actions":{
                            "supported":null
                        }
                    }
                ],
                "additional":null
            }
        ],
        "extend":""
    },
    "endpoint":{
        "scope":{
            "type":"BearToken",
            "token":"8e8918f6a5e488126d601da83ea2dfc33c93b285b699c2e3534b9c02118ddf0416025dbace576b9463702aed9e0c6fe3"
        }
    }
}
}

对端需提供推送响应:不做要求

错误响应

查询湿度 接口名称:DNA.ErrorResponse

响应

 {
   "context": {},
   "event": {
       "header": {
       "namespace": "DNA",
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "ErrorResponse",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
         "type": "ENDPOIONT_UNREACHABLE",
         "message":"设备离线"
     }
   }
 }
 {
   "context": {},
   "event": {
       "header": {
       "namespace": "DNA",
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "ErrorResponse",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
         "type": "VALUE_OUT_OF_RANGE",
         "message":"值越界",
         "validRange": {
             "minimumValue":10,
             "maximumValue":200
         }
     }
   }

场景控制

控制场景

接口名称: DNA.SceneControl

请求例子

 {
   "directive": {
     "header": {
        "namespace": "DNA.SceneControl",
        "name": "Activate",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
     },
     "endpoint": {
       "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
       },
       "endpointId": "appliance-001",
       "cookie": {}
     },
     "payload": {
     }
   }
 }

响应例子

 {
   "context": {
   },
   "event": {
     "header": {
        "namespace": "DNA.SceneControl",
        "name": "ActivationStarted",
        "interfaceVersion": "2",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
     }
   }
 }

请求例子

 {
   "directive": {
     "header": {
        "namespace": "DNA.SceneControl",
        "name": "Deactivate",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
     },
     "endpoint": {
       "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
       },
       "endpointId": "appliance-001",
       "cookie": {}
     },
     "payload": {
     	"taskid":"xxxx"
     }
   }
 }

响应例子

 {
   "context": {
   },
   "event": {
     "header": {
        "namespace": "DNA.SceneControl",
        "name": "DeactivationStarted",
        "interfaceVersion": "2",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
     }
   }
 }

运动控制

控制设备的动作,所有返回是统一的。

接口名称:DNA.MotionControl

   {
     "directive": {
       "header": {
         "namespace": "DNA.MotionControl",
         "name": "Start",
         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
         "interfaceVersion": "2"
       },
       "endpoint": {
         "scope": {
           "type": "BearerToken",
           "token": "<OAuth2认证后得到的access_token"
         },
         "endpointId": "<设备ID,发现时返回",
         "cookie": {
         }
       },
       "payload": {
       }
     }
   }
   {
     "directive": {
       "header": {
         "namespace": "DNA.MotionControl",
         "name": "Pause",
         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
         "interfaceVersion": "2"
       },
       "endpoint": {
         "scope": {
           "type": "BearerToken",
           "token": "<OAuth2认证后得到的access_token"
         },
         "endpointId": "<设备ID,发现时返回",
         "cookie": {
         }
       },
       "payload": {
       }
     }
   }
   {
     "directive": {
       "header": {
         "namespace": "DNA.MotionControl",
         "name": "Stop",
         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
         "interfaceVersion": "2"
       },
       "endpoint": {
         "scope": {
           "type": "BearerToken",
           "token": "<OAuth2认证后得到的access_token"
         },
         "endpointId": "<设备ID,发现时返回",
         "cookie": {
         }
       },
       "payload": {
       }
     }
   }
   {
     "context": {
       "properties": [
       ]
     },
     "event": {
         "header": {
         "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
         "name": "Response",
         "interfaceVersion": "2"
       },
       "endpoint": {
         "scope": {
           "type": "BearerToken",
           "token": "some-access-token"
         },
         "endpointId": "appliance-001"
       },
       "payload": {
       }
     }
   }

文本控制(暂时不开放)

通过文本字符串控制设备或者场景

接口名称: DNA.TextControl

请求例子

 {
   "directive": {
     "header": {
        "namespace": "DNA.TextControl",
        "name": "Request",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
     },
     "endpoint": {
       "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
       },
       "cookie": {}
     },
     "payload": {
       "text":"",
       "additionals":{}
     }
   }
 }

响应例子

 {
   "context": {
   },
   "event": {
     "header": {
        "namespace": "DNA.TextControl",
        "name": "Response",
        "interfaceVersion": "2",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
     },
     "payload": {
         "answerText":"",
         "endpoints":[
             {
                 "endpointId":"",
                 "actions": [{
                     "namespace":"",
                     "name":"",
                     "value":{}
                 }
                 ]
             }
         ]
     }
   }
 }

自定义面板控制

控制RM自定义面板,需要运维设置是否返回自定义面板

接口名称: DNA.CustomizedRemoteControl

请求例子

 {
   "directive": {
     "header": {
        "namespace": "DNA.CustomizedRemoteControl",
        "name": "打开",
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820",
     },
     "endpoint": {
       "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
       },
       "cookie": {}
     },
     "payload": {
     }
   }
 }

响应例子

 {
   "context": {
     "properties": []
   },
   "event": {
     "header": {
       "namespace": "DNA.CustomizedRemoteControl",
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "Response",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
     }
   }
 }

说明:

1.发现设备时能力中会返回自定义面板所支持的动作。

2.可以通过displayCategories中CUSTOMIZED来区分是否为自定义面板。

3.actions中的能力对应面板中保存的按键。

  {
            "endpointId":"3008880577263935437",
            "friendlyName":"自定义空调",
            "description":"BroadLink 智能遥控",
            "manufacturerName":"BroadLink",
            "icon":"https://ihcv0.ibroadlink.com/ec4appsysinfo/category2/CUSTOMIZED.png",
            "brand":"BroadLink",
            "roomName":"客厅",
            "displayCategories":[
                "CUSTOMIZED"
            ],
            "cookie":{
                "did":"xx",
                "pid":"10039",
                "sdid":"",
                "spid":"",
                "userid":"xx",
                "devtype":0,
                "devname":"自定义空调",
                "moduleid":"3008880577263935437",
                "moduletype":"20",
                "familyid":"004734ce018aba779d8961378fa720bb",
                "familyname":"我的家庭"
            },
            "isReachable":true,
            "capabilities":[
                {
                    "type":"DNAInterface",
                    "interface":"DNA.CustomizedRemoteControl",
                    "version":"2",
                    "properties":{
                        "supported":null,
                        "proactivelyReported":false,
                        "retrievable":false
                    },
                    "actions":{
                        "supported":[
                            {
                                "name":"打开"
                            },
                            {
                                "name":"关闭"
                            }
                        ]
                    }
                }
            ],
            "additional":null
  }

透传控制

透传控制,需了解产品dna控制指令

接口名称: DNA.FreeControl

请求例子

 {
   "directive": {
     "header": {
        "namespace": "DNA.FreeControl",
        "name": "DnaCodeControl",//方便以后再添加原始指令透传控制
        "interfaceVersion": "2",
        "messageId": "1bd5d003-31b9-476f-ad03-71d471922820"
     },
     "endpoint": {
       "scope": {
          "type": "BearerToken",
          "token": "some-access-token"
       },
       "endpointid":"appliance-001",
       "cookie": {}
     },
     "payload": {
       "dnaCode":"{\"tpid\":\"003\",\"srv\":\"1.1.1.1\",\"vals\":[[{\"val\":1,\"idx\":1}]],\"params\":[\"pwr\"],\"act\":\"get\",\"prop\":\"stdctrl\"}"
     }
   }
 }

响应例子

 {
   "context": {
     "properties": [
       {
         "namespace": "DNA.FreeControl",
         "name": "dnaCode",
         "value":"{\"tpid\":\"003\",\"srv\":\"1.1.1.1\",\"vals\":[[{\"val\":1,\"idx\":1}]],\"params\":[\"pwr\"],\"act\":\"get\",\"prop\":\"stdctrl\"}",
         "timeOfSample": "2017-02-03T16:20:50.52Z",
       }
     ]
   },
   "event": {
     "header": {
       "namespace": "DNA.FreeControl",
       "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
       "name": "Response",
       "interfaceVersion": "2"
     },
     "endpoint": {
       "scope": {
         "type": "BearerToken",
         "token": "some-access-token"
       },
       "endpointId": "appliance-001"
     },
     "payload": {
       "dnaCodeResp":"{\"errcode\":0,\"params\":[\"pwr\"],\"vals\":[[{\"idx\":1,\"val\":0}]]}"
     }
   }
 }

帐号主动授权

第三方主动授权。

接口名称:DNA.Authorization

   {
     "directive": {
       "header": {
         "namespace": "DNA.Authorization",
         "name": "AcceptGrant",
         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
         "interfaceVersion": "2"
       },
       "payload": {
           "grant": {
               "type": "OAuth2.AuthorizationCode",
               "code": "some-oauth-code",
               "clientid":"clientid"
           },
           "grantee": {
               "type": "BearerToken",
               "token":"some-oauth-token"
           }//暂时不使用
       }
     }
   }
   {
     "event": {
         "header": {
         "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
         "namespace": "DNA.Authorization",
         "name":"AcceptGrant.Response",
         "interfaceVersion": "2"
       },
       "payload": {
           "grantee": {
               "type": "BearerToken",
               "token":"some-oauth-token",
               "refreshToken":"some-oauth-token"
               "expiresin":""//秒
           }
       }
     }
   }

接收到主动授权消息后,BroadLink云端会调用OAuth2.0协议调用第三方提供的OAuth2.0 token获取与刷新接口以及获取用户信息接口,完成OAuth2.0流程。

如果之前没有进行过授权,那么grantee中的token为空。这一步授权完成后,通过设备发现消息,可以查询 到授权消息中携带的设备。

设备授权

第三方设备授权。

接口名称:DNA.Authorization

   {
     "directive": {
       "header": {
         "namespace": "DNA.Authorization",
         "name": "DeviceGrant",
         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
         "interfaceVersion": "2"
       },
       "endpoint": {
         "scope": {
           "type": "BearerToken",
           "token": "<OAuth2认证后得到的access_token"
         },
         "devicePairedInfo":devicePairedInfo,
         "cookie": {}
       }
     }
   }
   {
     "event": {
       "header": {
         "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
         "namespace": "DNA.Authorization",
         "name": "DeviceGrant.Response",
         "interfaceVersion": "2"
       },
       "payload": {
         "device": {
           "devicePairedInfo": devicePairedInfo, //与查询相同
           "cookie": {} //与查询相同
         }
       },
       "endpoints": {
         "event": {
           "header": {
             "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
             "namespace": "DNA.Authorization",
             "name": "DeviceGrant.Response",
             "interfaceVersion": "2"
           },
           "payload": {
             "device": {
               "deviceInfo": "",
               "cookie": {}
             }
           },
           "endpoints": [{
             "endpointId": "appliance-001", //设备的,一般为sdk设备发现的did
             "friendlyName": "卧室灯", //设备的默认名称
             "description": "由BroadLink生产的灯",
             "manufacturerName": "Sample Manufacturer",
             "icon": "产品图片URL",
             "brand": "品牌",
             "displayCategories": [
               "LIGHT"
             ],
             "cookie": {
               "extraDetail1": "某些设备可能会用到这个cookie,需要在控制时原样返回",
               "extraDetail2": "某些设备可能会用到这个cookie,需要在控制时原样返回",
               "extraDetail3": "某些设备可能会用到这个cookie,需要在控制时原样返回",
               "extraDetail4": "某些设备可能会用到这个cookie,需要在控制时原样返回"
             },
             "capabilities": [{
               "type": "DNAInterface",
               "interface": "DNA.PowerControl",
               "version": "2",
               "properties": {
                 "supported": [{
                   "name": "powerState"
                 }],
                 "proactivelyReported": true,
                 "retrievable": true
               },
               "actions": {
                 "supported": [{
                   "name": "ChangePowerState"
                 }]
               }
             }]
           }]
         }
       }
     }
   }

其中devicePairedInfo由本地局域网设备配对返回.格式如下:

 {
   "did":"",      //设备的唯一ID
   "pid":"",      //设备产品类型ID
   "mac":"",      //设备MAC地址
   "cookie":""    //设备Pair获取Cookie
 }

产品详情查询

设备产品详情查询。

接口名称:DNA.ProductInfo

   {
     "directive": {
       "header": {
         "namespace": "DNA.ProductInfo",
         "name": "ProductQuery",
         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
         "interfaceVersion": "2"
       },
       "endpoint": {
           "devicePairedInfo":devicePairedInfo,
           "cookie":{}//后续扩展使用
       },
       "payload": {
           "scope":{
           }
       }
     }
   }

其中devicePairedInfo由本地局域网设备配对返回.格式如下:

 {
   "did":"",      //设备的唯一ID
   "pid":"",      //设备产品类型ID
   "mac":"",      //设备MAC地址
   "cookie":""    //设备Pair获取Cookie
 }
   {
     "event": {
         "header": {
         "messageId": "30d2cd1a-ce4f-4542-aa5e-04bd0a6492d5",
         "namespace": "DNA.ProductInfo",
         "name":"ProductQuery.Response",
         "interfaceVersion": "2"
       },
       "endpoints":[
              {
               "friendlyName": "卧室灯",
               "description": "由BroadLink生产的灯",
               "manufacturerName": "Sample Manufacturer",
               "icon":"产品图片URL",
               "brand":"品牌",
               "displayCategories": [
                   "LIGHT"
               ],
               "familyName": "用户设置的家庭名称",
               "roomName": "用户设置的房间名称",
               "cookie": {
                   "extraDetail1": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                   "extraDetail2": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                   "extraDetail3": "某些设备可能会用到这个cookie,需要在控制时原样返回",
                   "extraDetail4": "某些设备可能会用到这个cookie,需要在控制时原样返回"
               },
               "capabilities": [
                   {
                       "type": "DNAInterface",
                       "interface": "DNA.PowerControl",
                       "version": "2",
                       "properties": {
                           "supported": [
                               {
                                   "name": "powerState"
                               }
                           ],
                           "proactivelyReported": true,
                           "retrievable": true
                       },
                      "actions": {
                          "supported": [
                           {
                                "name": "ChangePowerState"
                           }
                          ]
                      }
                   }
               ]
           }
       ],
       "payload": {
       }
     }
   }

设备状态查询

设备状态查询。

接口名称:DNA

url:https://域名/dnaproxy/v2/statereport?license=xxxx

body:

   {
     "directive": {
       "header": {
         "namespace": "DNA",
         "name": "StateReport",
         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
         "payloadVersion": "2"
       },
       "endpoint": {
           "endpointId":"",
           "scope":{
             "type":"",
             "token":""
           },
           "cookie":{
             "pid":""//实际为devtype
           }
       },
       "payload": {
       }
     }
   }
   {
     "context":{
      "properties":[
        {
          "namespace":"DNA.EndpointHealth",
          "name":"connectivity",
          "value":{
            "state":"OK",
            "lastContact":"2006-01-02T15:04:05.00Z",
          }
        }
      ]
     },
     "directive": {
       "header": {
         "namespace": "DNA",
         "name": "StateReport",
         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
         "payloadVersion": "2"
       },
       "endpoint": {
           "endpointId":"",
           "scope":{
             "type":"",
             "token":""
           },
           "cookie":{
             "pid":""//实际为devtype
           }
       },
       "payload": {
       }
     }
   }

错误或离线响应:

   {
     "directive": {
       "header": {
         "namespace": "DNA",
         "name": "ErrorResponse",
         "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
         "payloadVersion": "2"
       },
       "endpoint": {
           "endpointId":"",
           "scope":{
             "type":"",
             "token":""
           },
           "cookie":{
             "pid":""//实际为devtype
           }
       },
       "payload": {
         "type":"ENDPOINT_UNREACHABLE",
         "message":"Unable to reach endpoint"
       }
     }
   }

其他参考表


智能家居接口属性参考表

接口错误消息参考表

品类参考表

智能接口参考表