# 智能家居协议

## 简介

智能家居协议是右转智能主机与智能家居设备之间的通讯协议。通过这些协议您可以通过语音，主机上的图形界面控制家里的智能设备，与设备进行交互。智能家居协议使用HTTPS传输，协议采用JSON消息格式。

## 协议说明

### 身份认证

智能家居协议遵循OAuth2.0规范。 从右转智能主机发送到智能设备的每个请求都包含OAuth的access token。

### 组成说明

智能家居协议由Header和Payload两部分组成。

**Header信息**

Header包含消息标识符、指令名称、命令空间和payload版本信息。

```yaml
{
    "header": {        
        "namespace": "YouZhuan.ConnectedHome.Discovery",
        "name": "DiscoverAppliancesRequest",
        "messageId": "xxxxx-xxxx-xxxx-xxx",
        "payloadVersion": "1"
    }
}
```

**Header属性说明**

Header包含的属性及属性说明。

| 属性             | 属性说明                                                                                                                            | 是否必须 |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------- | ---- |
| namespace      | <p>指令的类别。</p><p>目前支持的类别有：</p><p>1: YouZhuan.ConnectedHome.Discovery：发现设备指令。</p><p>2: YouZhuan.ConnectedHome.Control：控制设备指令。</p> | 是    |
| name           | 指令的名称。                                                                                                                          | 是    |
| messageId      | <p>消息的唯一标识符，messageId仅用于标识消息</p><p>无其他使用。建议使用随机生成的UUID作为messageId。</p>                                                          | 是    |
| payloadVersion | payload的版本号。                                                                                                                    | 是    |

#### Payload信息

Payload的内容与Header中的name值相关，不同类型的指令，Payload内容也不相同。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.youzhuan.net/dev-link-host/zhi-neng-jia-ju-xie-yi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
