无法触发Alexa发送GetWeeklySchedule指令的技术咨询
问题:Alexa恒温器接口无法触发GetWeeklySchedule指令且无日程修改选项
我用Node.js开发了对接AWS/Alexa的恒温器接口,目前能在Alexa App中获取设定值、当前温度以及「按日程控制」状态,但无法触发Alexa发送GetWeeklySchedule指令,同时App里也没有日程修改的选项。
以下是我的发现响应和状态报告响应代码:
发现响应
{ endpointId: endpointId, manufacturerName: 'Me', description: description, friendlyName: friendlyName, displayCategories: ["THERMOSTAT"], cookie: {}, capabilities: [ { interface: 'Alexa.ThermostatController', version: '3.1', type: 'AlexaInterface', properties: { supported: [ { name: 'targetSetpoint' }, { name: 'thermostatMode' } ], proactivelyReported: false, retrievable: true }, configuration: { supportedModes: ["HEAT", "OFF"], supportsScheduling: true } }, { type: 'AlexaInterface', interface: 'Alexa.TemperatureSensor', version: '3', properties: { supported: [ { name: 'temperature' } ], proactivelyReported: false, retrievable: true }, }, { type: "AlexaInterface", interface: "Alexa.ThermostatController.Schedule", version: "3.2", properties: { supported: [ { name: "scheduleEnabled" } ], proactivelyReported: false, retrievable: true }, configuration: { supportedFanModes: ["AUTO"], supportsAdaptiveRecovery: false } }, { type: 'AlexaInterface', interface: 'Alexa', version: '3' } ] }
状态报告响应
{ namespace: 'Alexa.ThermostatController', name: 'thermostatMode', value: info.deviceMode, timeOfSample: new Date().toISOString(), uncertaintyInMilliseconds: 500 } { namespace: 'Alexa.ThermostatController', name: 'targetSetpoint', value: { value: info.deviceSetPoint, scale: 'FAHRENHEIT' }, timeOfSample: new Date().toISOString(), uncertaintyInMilliseconds: 500 } { namespace: 'Alexa.TemperatureSensor', name: 'temperature', value: { value: info.deviceTemperature, scale: 'FAHRENHEIT' }, timeOfSample: new Date().toISOString(), uncertaintyInMilliseconds: 500 } { namespace: 'Alexa.ThermostatController.Schedule', name: 'adaptiveRecoveryEnabled', value: false, timeOfSample: new Date().toISOString(), uncertaintyInMilliseconds: 500 } { namespace: 'Alexa.ThermostatController.Schedule', name: 'scheduleEnabled', value: true, timeOfSample: new Date().toISOString(), uncertaintyInMilliseconds: 500 }
问题根源
Alexa.ThermostatController.Schedule接口配置不完整:当前仅声明了scheduleEnabled属性支持,但Alexa需要明确感知到设备支持周度日程的读写能力才会触发GetWeeklySchedule指令,并在App中显示日程修改选项。- 缺少关键配置参数:未在
configuration中声明支持日程修改和指定日程类型,导致Alexa无法识别设备的日程交互能力。
修复方案
1. 更新发现响应中的Alexa.ThermostatController.Schedule配置
修改该接口的properties.supported和configuration部分,添加周度日程支持及修改权限:
{ type: "AlexaInterface", interface: "Alexa.ThermostatController.Schedule", version: "3.2", properties: { supported: [ { name: "scheduleEnabled" }, { name: "weeklySchedule" } // 新增周度日程属性支持 ], proactivelyReported: false, retrievable: true }, configuration: { supportedFanModes: ["AUTO"], supportsAdaptiveRecovery: false, supportsScheduleModification: true, // 明确标记支持日程修改 supportedScheduleTypes: ["WEEKLY"] // 指定支持周度日程类型 } }
2. 实现GetWeeklySchedule指令处理逻辑
在Node.js代码中添加对应指令的处理,返回设备当前的周度日程数据:
// 示例处理逻辑 if (directive.namespace === 'Alexa.ThermostatController.Schedule' && directive.name === 'GetWeeklySchedule') { // 从设备或数据库获取周日程数据 const weeklySchedule = { scheduleItems: [ { dayOfWeek: "MONDAY", startTime: "07:00:00", targetSetpoint: { value: 72, scale: "FAHRENHEIT" }, thermostatMode: "HEAT" }, // 补充其他日期的日程项 ] }; return { context: { properties: [ { namespace: 'Alexa.ThermostatController.Schedule', name: 'weeklySchedule', value: weeklySchedule, timeOfSample: new Date().toISOString(), uncertaintyInMilliseconds: 500 } ] }, event: { header: { namespace: 'Alexa.ThermostatController.Schedule', name: 'GetWeeklyScheduleResponse', messageId: directive.header.messageId + '-R', payloadVersion: '3.2' }, payload: {} } }; }
3. 可选:添加SetWeeklySchedule指令处理
若需要支持Alexa App修改日程,需实现该指令的处理逻辑,接收并更新设备的日程配置。
验证步骤
- 重新部署修改后的发现响应代码。
- 在Alexa App中重新发现设备。
- 进入设备详情页,检查是否出现日程修改选项。
- 通过Alexa开发者控制台测试工具,触发
GetWeeklySchedule指令,确认后端能正常响应。
内容的提问来源于stack exchange,提问作者John Smith
相关产品推荐
相关产品推荐

