智能家居接入协议

一、概述

智能家居协议是智能家居技能与DUI SERVER之间的通讯协议。基于这些协议可以轻松的通过语音控制家里的智能设备,与设备进行交互。

智能家居协议使用HTTPS传输,协议采用JSON消息格式。

注:

1)关于请求的响应, 其response header 的Content-Type 头部需要是 application/json 格式;
2)DUI SERVER请求厂商服务接口目前设置的超时时间为2秒,如果出现服务不可用的情况,请接入方进行优化;
3)家居协议的请求采用POST请求。

二、认证方式

智能家居协议遵循OAuth2.0规范。协议交互的每个请求都需要包含OAuth的access token。

三、协议内容

智能家居协议主要分为两部分: header 及 payload ( 均为HTTPS请求的BODY部分 )。

3.1 header参数

Header包含指令空间、指令名称、payloadVersion和消息标识符。

参数名 参数类型 参数说明 是否必须
namespace string DUI.SmartHome.Discovery
DUI.SmartHome.Control
DUI.SmartHome.Query
name string 具体操作指令的名称,如:“TurnOn”,“etVolume”等
payloadVersion int payload的版本号,当前全部传1
messageId string 消息的唯一标识符,可用于跟踪请求

3.2 payload参数

Payload的内容与Header中的具体指令相关,不同类型的指令,其payload内容也不相同。

这里仅罗列各个请求中的典型参数,具体传参请查阅各个指令的详细设计。

参数名 参数类型 参数说明
accessToken string 云端获取的accessToken
appliances.applianceld string 设备ID
appliances.applianceType string 设备类型,设备商只能传规定值。目前支持以下设备:
LIGHT:电灯
SWITCH:开关
SOCKET:插座
AIR_CONDITION:空调
TV_SET:电视
AIR_PURIFIER:空气净化器
FAN:电风扇
WATER_HEATER:热水器
HEATER:电暖器
WASHING_MACHINE:洗衣机
GAS_STOVE:燃气灶
RANGE_HOOD:油烟机
OVEN:烤箱
MICROWAVE_OVEN:微波炉
PRESSURE_COOKER:电压力锅
RICE_COOKER:电饭煲
INDUCTION_COOKER:电磁炉
HIGH_SPEED_BLENDER:破壁机
SWEEPING_ROBOT:扫地机器人
FRIDGE:冰箱
HUMIDIFIER:加湿器
SET_TOP_BOX:机顶盒
SENSOR:传感器
CURTAIN:窗帘
appliances.friendlyName string 用户用来识别设备的名称
appliances.manufacturerName string 设备厂商
appliances.modelName string 设备型号
appliances.zone string 设备的位置
appliances.actions json
array
设备支持的操作指令,目前合法的action包括:
TurnOn:打开
TurnOff:关闭
TimingTurnOn:定时打开
TimingTurnOff:定时关闭
Pause:暂停
Continue:取消暂停
SetZone: 设置设备位置
SetBrightness:设置灯光亮度
IncreaseBrightness:调大亮度(含步长)
DecreaseBrightness:调小亮度(含步长)
SetTemperature:设置温度
IncreaseTemperature:升高温度(含步长)
DecreaseTemperature:降低温度(含步长)
SetVolume:设置音量
IncreaseVolume:调高音量
DecreaseVolume:调低音量
SetMute:设置静音状态
CancelMute:取消静音状态
IncreaseWindSpeed:增加风速
DecreaseWindSpeed:减小风速
SetWindSpeed:设置风速(0-3,auto-max)
SetMode:设置模式
SetHumidity:设置湿度
SetChannel:设置频道号
SetChannelName:设置频道名称
IncreaseChannel:向前跳N个频道
DecreaseChannel:向后跳N个频道
SetUpWind:向上调整风向
SetDownWind:向下调整风向
SetLeftWind:向左调整风向
SetRightWind:向右调整风向
SetUpAndDownWind:上下摆风
SetRightAndLeftWind:左右摆风
CloseSwing:关闭摆风
SetColor:设置颜色
SetOpenDegree:设置打开程度
IncreaseOpenDegree:调大打开程度(含步长)
DecreaseOpenDegree:调小打开程度(含步长)
appliances.description string 设备的描述信息
appliances.additionalApplianceDetails json
object
供给设备云使用,存放设备相关的附加信息。DUI不关注不使用这些数据,如果设备信息包含此字段,DUI控制设备时将原样返回,最大长度不能超过2000字节

3.3 模式对照表

对于支持模式的设备,不同的类型可以控制的模式也不同。下面***仅列出支持模式设置的设备***及其对应的模式:

设备类型 设备模式
AIR_CONDITION COOL:制冷
HEAT:制热
AUTO:自动
FAN:送风
DEHUMIDIFICATION:除湿
SLEEP:睡眠
AIR_PURIFIER SLEEP:睡眠
HOME:回家
OUT:离家
AUTO:自动
MANUAL:手动
MUTE:静音
INTELLIGENT:智能
HIGHSPEED:急速
DUST:除尘
HCHO_FREE:除甲醛
INDUCTION_COOKER QUICK_FIRE:快速火
SLOW_FIRE:温火
FRYING:煎炸
STEWING:蒸煮/炖煮
SOUP:汤粥/煲汤
HOT_POT:火锅
COOKING:炒菜
SWEEPING_ROBOT RANDOM:随机
AUTO:自动
FOCUS:重点
EDGE:沿边
BOW:弓形
MICROWAVE_OVEN MICROWAVE:微波
BARBECUE:烧烤
THAW:解冻
OVEN FERMENTATION:发酵
DOUBLE_TUBE:烧烤
THAW:双管
RICE_COOKER HOTTING:加热/热饭/再加热
INSULATED:保温
SOUP:煮粥/煲汤/杂粮粥
FAST_SOUP:快速粥
STEWING:蒸煮/炖煮/美味蒸
NORMAL_RICE:蒸米饭
MIXED_RICE:杂粮饭
SMALL_RICE:小米饭
GERMINATED_RICE:发芽饭
WASHING_MACHINE STANDARD:标准
DRY:干洗
WASH_DRY:洗烘
FAST_WASH:快洗
DOWN_JACKET:羽绒服
FRIDGE INTELLIGENT:智能
FAST_FREEZE:速冻
MANUAL:手动设定
ICE_DRINK:冰饮功能
HUMIDIFIER AUTO:自动
SLEEP:睡眠
STANDARD:标准
LOW_HUMIDITY:低湿
HIGH_HUMIDITY:高湿

3.4 支持设置的颜色表

支持控制的颜色 中文描述
Red 红色
Yellow 黄色
Blue 蓝色
Green 绿色
White 白色
Black 黑色
Cyan 青色
Purple 紫色
Orange 橙色

注:若上述颜色厂商对应表中无,请近似匹配

3.5 设备属性的规格说明

属性名称 增量型名称 中文含义 取值范围 说明
brightness deltaBrightness 亮度 0-100 亮度的百分比(对于增量型属性,数值为绝对值,只表征变化量)
volume deltaVolume 音量 0-100 音量的百分比(对于增量型属性,数值为绝对值,只表征变化量)
temperature deltaTemperature 温度 -30-100 温度的数值,单位ºC(对于增量型属性,数值为绝对值,只表征变化量)
channel deltaChannel 频道号 0-1000 频道号(对于增量型属性,数值为绝对值,只表征变化量)
channelName 无增量形式 频道名称 string “中央一套”,“东方卫视”,“湖南卫视” 等标准频道名称
speedLevel deltaSpeedLevel 风速 1-4
风扇类:(1档,2档,3档,4档)
空调类:(自动,低,中,高)
风速的等级(对于增量型属性,数值为绝对值,只表征变化量)
仅支持增量形式 deltaAngel 风向角度 0-180(角度) 风向偏转的角度(对于增量型属性,数值为绝对值,只表征变化量)
humidity deltaHumidity 湿度 0-100 相对湿度的百分比(对于增量型属性,数值为绝对值,只表征变化量)
mode 无增量形式 模式 string 模式名称,参见 “3.3模式对照表”
color 无增量形式 颜色 string 颜色的名称,参见 “3.4支持设置的颜色表”
openDegree deltaOpenDegree 设备的打开程度 0-100 窗帘等设备的打开程度百分比(对于增量型属性,数值为绝对值,只表征变化量)

四、指令设计

4.1设备发现

请求


{
    "header":{
        "namespace":"DUI.SmartHome.Discovery",
        "name":"Discover",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token"
    }
}

响应


{
    "header":{
        "namespace":"DUI.SmartHome.Discovery",
        "name":"DiscoverResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "appliances":[
            {
                "applianceId":"xxxxx",
                "friendlyName":"多孔插座",
                "applianceType":"SOCKET",
                "manufacturerName":"xxxxx",
                "modelName":"xxxx",
                "zone":"客厅",
                "discription":"",
                "actions":[
                    "TurnOn",
                    "TurnOff"
                ],
                "additionalApplianceDetails":{
                    "extraDetail1":"xxxx",
                    "extraDetail2":"xxxx",
                    "extraDetail3":"xxxx",
                    "extraDetail4":"xxxx"
                }
            },
            {
                "applianceId":"xxxxx",
                "friendlyName":"灯",
                "applianceType":"LIGHT",
                "manufacturerName":"xxxxx",
                "modelName":"xxxx",
                "zone":"客厅",
                "discription":"",
                "actions":[
                    "TurnOn",
                    "TurnOff"
                ],
                "additionalApplianceDetails":{}
            },
            {
                "applianceId":"xxxxx",
                "friendlyName":"单孔插座",
                "applianceType":"SOCKET",
                "manufacturerName":"xxxxx",
                "modelName":"xxxx",
                "zone":"客厅",
                "discription":"",
                "actions":[
                    "TurnOn",
                    "TurnOff"
                ],
                "additionalApplianceDetails":{}
            }
        ]
    }
}

4.2设备控制

4.2.1 打开设备

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"TurnOn",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"TurnOnResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.2 关闭设备

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"TurnOff",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922869",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        }
    }
}

响应

 {
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"TurnOffResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922869",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.3 定时打开设备

请求


{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"TimingTurnOn",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922869",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "timestamp":{
            "value":1524030874
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"TimingTurnOnResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922869",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.4 定时关闭设备

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"TimingTurnOff",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922869",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "timestamp":{
            "value":1524030874
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"TimingTurnOffResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922869",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.5 设备暂停

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"Pause",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"PauseResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.6 取消暂停

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"Continue",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"ContinueResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.7 设置亮度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetBrightness",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "brightness":{
            "value":50
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetBrightnessResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.8 调大亮度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseBrightness",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaBrightness":{
            "value":20
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseBrightnessResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.9 调小亮度

请求

    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseBrightness",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaBrightness":{
            "value":10
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseBrightnessResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.10 设置温度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetTemperature",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "temperature":{
            "value":26
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetTemperatureResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.11 调大温度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseTemperature",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaTemperature":{
            "value":3
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseTemperatureResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.12 调小温度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseTemperature",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaTemperature":{
            "value":5
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseTemperatureResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.13 设置音量

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetVolume",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "volume":{
            "value":60
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetVolumeResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.14 调大音量

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseVolume",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaVolume":{
            "value":20
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseVolumeResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.15 调小音量

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseVolume",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaVolume":{
            "value":20
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseVolumeResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.16 设置静音

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetMute",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetMuteResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.17 取消静音

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"CancelMute",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"CancelMuteResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.18 设置频道

请求(按频道号设置)

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetChannel",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "channel":{
            "value":12
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetChannelResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

请求(按频道名称设置)

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetChannelName",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "channelName":{
            "value":"湖南卫视"
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetChannelNameResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.19 向前跳N个频道

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseChannel",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaChannel":{
            "value":3
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseChannelResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.20 向后跳N个频道

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseChannel",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaChannel":{
            "value":4
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseChannelResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.21 设置风速

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetWindSpeed",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "speedLevelLevel":{
            "value":2
        }
    }
}

响应


{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetWindSpeedResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.22 增大风速

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseWindSpeed",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaSpeedLevel":{
            "value":1
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseWindSpeedResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.23 减小风速

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseWindSpeed",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaSpeedLevel":{
            "value":2
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseWindSpeedResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.24 设置湿度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetHumidity",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "humidity":{
            "value":30
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetHumidityResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.25 增大湿度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseHumidity",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaHumidity":{
            "value":20
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseHumidityResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.26 减小湿度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseHumidity",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaHumidity":{
            "value":10
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseHumidityResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.27 设置模式

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetMode",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "mode":{
            "deviceType":"AIR_CONDITION",
            "value":"COOL"
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetModeResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.28 向上调整风向

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetUpWind",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaAngel":{
            "value":30
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetUpWindResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.29 向下调整风向

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetDownWind",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaAngel":{
            "value":20
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetDownWindResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.30 向左调整风向

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetLeftWind",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaAngel":{
            "value":30
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetLeftWindResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.31 向右调整风向

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetRightWind",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaAngel":{
            "value":30
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetRightWindResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.32 上下摆风

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetUpAndDownWind",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetUpAndDownWindResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.33 左右摆风

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetRightAndLeftWind",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{

            }
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetRightAndLeftWindResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.34 设置颜色

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetColor",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "color":{
            "value":"Yellow"
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetColorResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.35 设置打开程度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetOpenDegree",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "openDegree":{
            "value":50
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"SetOpenDegreeResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.36 调大打开程度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseOpenDegree",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaOpenDegree":{
            "value":30
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"IncreaseOpenDegreeResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.37 调小打开程度

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseOpenDegree",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        },
        "deltaOpenDegree":{
            "value":10
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"DecreaseOpenDegreeResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.2.38 关闭摆风

请求

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"CloseSwing",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{

            }
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Control",
        "name":"CloseSwingResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
    }
}

4.3 设备查询

4.3.1 支持的查询属性列表

属性名 heander name 说明 属性类型 备注
powerState QueryPowerState 电源状态 string “on”(通电状态),“off”(断电状态)
temperature QueryTemperature 温度 int -30-100(单位ºC)
speedLevel QueryWindSpeed 风速 int 1-4
风扇类: (1档,2档,3档,4档)
空调类: (自动,低,中,高)
brightness QueryBrightness 亮度 int 0-100(亮度百分比)
humidity QueryHumidity 湿度 int 0-100(相对湿度百分比)
channel QueryChannel 频道号 int 0-1000(频道号)
channelName QueryChannelName 频道名称 string “中央一套”,“东方卫视'”等 (必须为标准频道名称)
color QueryColor 颜色 string 参见“4.3.2支持查询的颜色列表”
PM25 QueryPM25 PM2.5 int 0-1000(浓度值)
AQI QueryAQI 空气质量 int 1-6(优,良,轻度,中度,重度,严重)
mode QueryMode 模式 string 参见 “3.3模式对照表”

4.3.2 支持查询的颜色列表

支持查询的颜色 中文描述
Red 红色
Yellow 黄色
Blue 蓝色
Green 绿色
White 白色
Black 黑色
Cyan 青色
Purple 紫色
Orange 橙色
Pink 粉红
Violet 紫罗兰
Magenta 洋红
Indigo 靛青
SlateBlue 蓝灰色
DarkBlue 深蓝色
SkyBlue 天蓝色
DarkCyan 深青色
Beige 浅褐色
Brown 棕色

注:若上述颜色厂商对应表中无,请近似匹配。

4.3.2 查询单个属性

请求

{   
 "header":{
        "namespace":"DUI.SmartHome.Query",
        "name":"QueryTemperature",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "accessToken":"access token",
        "appliance":{
            "applianceId":"123456789",
            "additionalApplianceDetails":{}
        }
    }
}

响应

{
    "header":{
        "namespace":"DUI.SmartHome.Query",
        "name":"QueryTemperatureResponse",
        "messageId":"1bd5d003-31b9-476f-ad03-71d471922820",
        "payloadVersion":1
    },
    "payload":{
        "temperature":{
            "value":30
        }
    }
}

4.4 错误信息

错误响应 header 协议中name固定为 “ErrorResponse”;

“namespace”,“messageId”,“payloadVersion”三个参数使用请求消息中对应字段内容。

payload字段说明如下:

error code 说明 message
SERVICE_ERROR 服务异常 服务错误原因
DEVICE_NOT_SUPPORT_FUNCTION 设备不支持该操作 device not support
INVALIDATE_PARAMS 请求参数有误 invalidate params
DEVICE_IS_NOT_EXIST 设备未找到 device is not exist
IOT_DEVICE_OFFLINE 设备离线状态 device is offline
ACCESS_TOKEN_INVALIDATE access_token 无效(包括失效) access_token is invalidate
VALUE_OUT_OF_RANGE 参数值超出有效值范围(如:温度,模式) value out of range

错误信息示例:

响应

{
    "header":{
        "namespace":"DUI.SmartHome.XXXXX",
        "name":"ErrorResponse",
        "messageId":"26fa11a8-accb-4f66-a272-8b1ff7abd722",
        "payloadVersion":1
    },
    "payload":{
        "errorCode":"ACCESS_TOKEN_INVALIDATE",
        "message":"access_token is invalidate"
    }
}

五、示例说法

DUI智能家居技能内置了丰富的指令说法,开发商不需要再进行说法的开发及定制。我们从中选取了一些常用的指令说法,以供测试及参考。

5.1 各指令示例说法

操作指令 说法示例
打开设备 “打开电灯”,“打开客厅的电灯”
关闭设备 “关闭空调”,“关闭卧室的窗帘”
定时打开 “一小时后打开电灯”,“一小时后打开客厅的空调”
定时关闭 “一小时后关闭电灯”,“一小时后关闭卧室的空调”
设备暂停 “洗衣机暂停一下”,“卫生间的洗衣机暂停一下”,“暂停洗衣机”,“暂停卫生间的洗衣机”
取消暂停 “洗衣机取消暂停”,“卫生间的洗衣机取消暂停”,“取消暂停洗衣机”
设置亮度 “灯亮度调到百分之五十”,“客厅的灯亮度调到百分之五十”
调大亮度 “把灯调亮一些”,“把客厅的灯调亮一些”,“卧室的灯度调亮百分之二十”
调小亮度 “把灯调暗一些”,“把客厅的灯调暗一些”,“卧室的灯度调暗百分之二十”
设置温度 “空调温度调到二十六度”,“卧室的空调温度调到二十六度”
调高温度 “空调的温度调高点”,“调高客厅的空调温度”,“客厅的空调温度调高三度”,“调高客厅空调的温度三度”
调低温度 “空调的温度调低点”,“调低客厅的空调温度”,“客厅的空调温度调低三度”,“调低客厅空调的温度三度”
设置音量 “电视音量调到六十”,“客厅的电视音量调到六十”
调高音量 “调高电视的音量”,“客厅的电视音量调大二十”
调低音量 “调低电视的音量”,“客厅的电视音量调低二十”
设置静音 “电视静音”,“客厅的电视静音”,“客厅的电视调成静音”
取消静音 “取消电视静音”,“客厅的电视取消静音”,“取消客厅电视的静音”
设置频道 “电视频道调到十二”,“电视频道调到十二台”,“客厅电视的频道调到十二”,“电视频道调到湖南卫视”,“电视调到东方卫视”
向前调N个频道 “电视频道往前调三个”,“电视频道往前调三个台”,“电视往前调三个频道”,“电视往前调三个台”,“往前调三个电视频道”,“客厅的电视往前调三个频道”
向后调N个频道 “电视频道往后调三个”,“电视频道往后调三个台”,“电视往后调三个频道”,“电视往后调三个台”,“客厅的电视往后调三个频道”,“电视频道往回调三个台”,“往回调三个电视频道”,“电视往回调三个频道”
设置风速 “空调的风速设为中速”,“空调的风速设为高风”,“风扇的风速设置为二档”
增大风速 “调高空调的风速”,“调高风扇的风速”,“风扇的风速调高一档”,空调的风速调高一档”
减小风速 “调低空调的风速”,“调低风扇的风速”,“风扇的风速调低一档”,“空调的风速调低一档”
设置湿度 “加湿器湿度调到百分之三十”,“客厅的加湿器湿度调到百分之三十”
增大湿度 “加湿器湿度调高百分之十”,“客厅的加湿器湿度调高百分之十”
减小湿度 “加湿器湿度调低百分之十”,“客厅的加湿器湿度调低百分之十”
设置模式 “空调设为制冷模式”,“厨房的电饭煲设为保温模式”
向上调整风向 “空调的风向调高一点”,“空调的风向调高二十度”,“客厅空调的风向调高二十度”
向下调整风向 “空调的风向调低一点”,“空调的风向调低二十度”,“客厅空调的风向调低二十度”
向左调整风向 “空调的风向向左调一点”,“向左调一点空调的风向”,“空调的风向向左调二十度”,“风扇的风向向左调一点”
向右调整风向 “空调的风向向右调一点”,“向右调一点空调的风向”,“风扇的风向向右调二十度”,“风扇的风向向右调一点”
上下摆风 “空调设置上下摆风”,“客厅的空调设置上下摆风”
左右摆风 “空调设置左右摆风”,“客厅的空调设置左右摆风”,“客厅的风扇设置左右摆风”
设置颜色 “书房的台灯调成黄色”,“客厅的电灯调成蓝色”
设置打开程度 “卧室的窗帘打开百分之五十”,“客厅的窗帘打开百分之九十”
调大打开程度 “客厅的窗帘开大一些”,“客厅的窗帘调大百分之三十”,“客厅的窗帘再打开一些”,“客厅的窗帘再打开百分之三十”
调小打开程度 “客厅的窗帘再关闭一些”,“客厅的窗帘再关闭百分之三十”,“客厅的窗帘调小一些”,“客厅的窗帘调小百分之三十”
查询温度 “查一下空调的温度”,“查一下客厅空调的温度”
查询风速 “查一下空调的风速”,“查一下客厅风扇的风速”
查询亮度 “查一下灯的亮度”,“查一下客厅的灯的亮度”
查询湿度 “加湿器查一下湿度”,“客厅的净化器查一下湿度”
查询频道 “查一下电视频道”,“查一下客厅电视频道”,“客厅的电视查一下频道”
查询颜色 “查一下灯的颜色”,“查一下客厅灯的颜色”
查询模式 “查一下空调的模式”,“查一下客厅加湿器的模式”,“客厅的加湿器查一下模式”
查询PM25 “净化器查一下PM二点五”,“客厅的净化器查一下PM二点五”
查询空气质量 “净化器查一下空气质量”,“客厅的净化器查一下空气质量”