# 设备控制

### 运行流程图

![](/files/-MEWGS_zehYMdJR-Gj3y)

## 调用方法（applianceControl）

用户控制设备时会调用此方法applianceControl方法，携带参数ControlRequest,客户需要根据ControlRequest在此方法内实现自己的控制逻辑

```java
@Override
public void applianceControl(String controlRequest) {
    
}
```

## ControlRequest

携带设备被控制的设备对象[Appliance](/dev-link-host/android-link-sdk/she-bei-fa-xian.md#appliance-she-bei-dui-xiang)

当前的请求类型，可使用YzRequestCode类

values携带改变的参数值

如果是通过语音控制的,则可以通过values对象获取“voiceStr”的值

具体请参考[请求类型与数据参照](/dev-link-host/android-link-sdk/controlrequest-dui-zhao.md)

```java
    /**设备对象*/
    private Appliance appliance;
    /**请求类型*/
    @YzRequestCode
    private String type;
    /**请求携带的属性值*/
    private JSONObject values;
```

## 控制结果返回

由于设备控制结果可能不为同步,需要使用notifyHost方法通知智能主机更新数据

SdkAction.[CONTROLLER\_SUCCESS](/dev-link-host/android-link-sdk/action-shi-jian.md#controller_success)

控制成功时传递此Action

SdkAction.[CONTROLLER\_FAIL](/dev-link-host/android-link-sdk/action-shi-jian.md#controller_fail)

控制失败时传递此Action

SdkAction.[NOTIFY\_APPLIANCE\_CHANGE](/dev-link-host/android-link-sdk/action-shi-jian.md#notify_appliance_change)

设备状态改变时传递此Action

返回数据

```java
{
    "applianceId":"设备Id"
    "attributes":{
       
    }
}
```


---

# 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/android-link-sdk/she-bei-kong-zhi.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.
