单端点双可调光灯的Alexa智能家居技能建模方法问询
单端点双可调光灯的Alexa Smart Home Skill建模方案
由于Alexa.BrightnessController不支持多实例,无法在同一端点下重复挂载该接口,正确的建模方式是将两个灯光作为同一物理设备下的独立子端点实现,具体如下:
推荐方案:拆分独立子端点
将两个可调光灯分别定义为关联到主设备的子端点,每个子端点单独挂载Alexa.PowerController和Alexa.BrightnessController标准接口:
设备发现响应配置
主端点仅作为父实体存在,无需挂载灯光控制接口;两个灯光各自作为子端点,通过parentEndpointId与主端点关联,且各自设置唯一的friendlyName和displayCategories: ["LIGHT"]。示例JSON片段:
[ { "endpointId": "living-room-combo-light-main", "displayCategories": ["OTHER"], "friendlyName": "客厅组合灯", "capabilities": [] }, { "endpointId": "living-room-combo-light-main-1", "parentEndpointId": "living-room-combo-light-main", "displayCategories": ["LIGHT"], "friendlyName": "客厅主灯", "capabilities": [ { "type": "AlexaInterface", "interface": "Alexa.PowerController", "version": "3", "properties": { "supported": [{"name": "powerState"}], "proactivelyReported": true, "retrievable": true } }, { "type": "AlexaInterface", "interface": "Alexa.BrightnessController", "version": "3", "properties": { "supported": [{"name": "brightness"}], "proactivelyReported": true, "retrievable": true } } ] }, { "endpointId": "living-room-combo-light-main-2", "parentEndpointId": "living-room-combo-light-main", "displayCategories": ["LIGHT"], "friendlyName": "客厅氛围灯", "capabilities": [ { "type": "AlexaInterface", "interface": "Alexa.PowerController", "version": "3", "properties": { "supported": [{"name": "powerState"}], "proactivelyReported": true, "retrievable": true } }, { "type": "AlexaInterface", "interface": "Alexa.BrightnessController", "version": "3", "properties": { "supported": [{"name": "brightness"}], "proactivelyReported": true, "retrievable": true } } ] } ]用户交互优势
用户可通过自然语言分别控制两个灯光,比如:- "打开客厅主灯"
- "把客厅氛围灯的亮度调到50%"
Alexa能准确识别并执行对应指令,符合官方设备模型规范,稳定性和用户体验最优。
备选方案(不推荐):自定义扩展接口
若必须在单个端点实现,可自定义扩展接口(如Custom.DualLightController),在属性中分别存储两个灯光的亮度和开关状态(如light1Brightness、light2PowerState)。但这种方式存在以下问题:
- 需要用户使用非标准指令,交互体验差
- 不符合Alexa标准设备模型,易出现语音识别错误
- 无法利用Alexa内置的灯光控制语义解析能力
内容的提问来源于stack exchange,提问作者jamp
相关产品推荐
相关产品推荐

