alexa - 如何让 Alexa 连续执行按钮“SetLight”指令?
问题描述
我正在努力让 Alexa 使用两个按钮显示闪烁模式,每个按钮显示一秒钟的橙色,每个按钮显示半秒钟的黑色缓冲区。所以模式将是:
按钮 1 为 1 秒的橙色和半秒的黑色。
按钮 2 为一秒钟的橙色和半秒钟的黑色。
按钮 2 为一秒钟的橙色和半秒钟的黑色。
按钮 1 为一秒橙色和半秒黑色。
我正在尝试堆叠它们,但它从来没有真正起作用。这是我正在使用的代码:
this.response._addDirective({
"type": "GadgetController.SetLight",
"version": 1,
"targetGadgets": ["amzn1.ask.gadget.XXX1"],
"parameters": {
"triggerEvent": "none",
"triggerEventTimeMs": 0,
"animations": [{
"repeat": 1,
"targetLights": ["1"],
"sequence": [
{
"durationMs": 1000,
"blend": false,
"color": "000000"
},
{
"durationMs": 1000,
"blend": false,
"color": "b32d00"
}
]
}]
}
});
this.response._addDirective({
"type": "GadgetController.SetLight",
"version": 1,
"targetGadgets": ["amzn1.ask.gadget.XXXX2"],
"parameters": {
"triggerEvent": "none",
"triggerEventTimeMs": 0,
"animations": [{
"repeat": 1,
"targetLights": ["1"],
"sequence": [{
"durationMs": 1500,
"blend": false,
"color": "000000"
},
{
"durationMs": 1000,
"blend": false,
"color": "b32d00"
}
]
}]
}
});
this.response._addDirective({
"type": "GadgetController.SetLight",
"version": 1,
"targetGadgets": ["amzn1.ask.gadget.XXXX2"],
"parameters": {
"triggerEvent": "none",
"triggerEventTimeMs": 0,
"animations": [{
"repeat": 1,
"targetLights": ["1"],
"sequence": [
{
"durationMs": 2000,
"blend": false,
"color": "000000"
},
{
"durationMs": 1000,
"blend": false,
"color": "b32d00"
}
]
}]
}
});
this.response._addDirective({
"type": "GadgetController.SetLight",
"version": 1,
"targetGadgets": ["amzn1.ask.gadget.XXXX1"],
"parameters": {
"triggerEvent": "none",
"triggerEventTimeMs": 0,
"animations": [{
"repeat": 1,
"targetLights": ["1"],
"sequence": [
{
"durationMs": 2500,
"blend": false,
"color": "000000"
},
{
"durationMs": 1000,
"blend": false,
"color": "b32d00"
}
]
}]
}
});
我猜我的问题在于“无”触发事件相互抵消,但必须有办法做到这一点。有什么想法吗?
解决方案
我确实最终弄清楚了这一点,并想更新它以防其他人偶然发现它。
我试图在两个按钮上连续运行 4 个动画,但这是不可能的。每个按钮只能运行一个动画 (SetLight) 指令,因此在这种情况下,我最终使用了两个。一旦我改变了我的思维方式,我就可以制作两个动画,每个按钮一个对应的按钮亮一个,另一个是暗的。示例如下:
按钮 1 的 setLight 指令:
this.response._addDirective({
"type": "GadgetController.SetLight",
"version": 1,
"targetGadgets": [`${deviceIds[0]}`],
"parameters": {
"animations": [{
"repeat": 1,
"targetLights": ["1"],
"sequence": [{
"durationMs": 3000,
"blend": false,
"color": "000000"
},
{
"durationMs": 1000,
"blend": false,
"color": b32d00
},
{
"durationMs": 500,
"blend": false,
"color": "000000"
},
{
"durationMs": 1000,
"blend": false,
"color": 000000
},
{
"durationMs": 500,
"blend": false,
"color": "000000"
}
]
}],
"triggerEvent": "none",
"triggerEventTimeMs": 0
}
按钮 2 的 setLight 指令:
this.response._addDirective({
"type": "GadgetController.SetLight",
"version": 1,
"targetGadgets": [`${deviceIds[0]}`],
"parameters": {
"animations": [{
"repeat": 1,
"targetLights": ["1"],
"sequence": [{
"durationMs": 3000,
"blend": false,
"color": "000000"
},
{
"durationMs": 1000,
"blend": false,
"color": 000000
},
{
"durationMs": 500,
"blend": false,
"color": "000000"
},
{
"durationMs": 1000,
"blend": false,
"color": b32d00
},
{
"durationMs": 500,
"blend": false,
"color": "000000"
},
{
"durationMs": 10000,
"blend": false,
"color": "b32d00"
}
]
}],
"triggerEvent": "none",
"triggerEventTimeMs": 0
}
这就是基本的jist,希望它可以帮助别人。
推荐阅读
- python - 如何获得自动编码器生成的压缩表示?
- rest - WCF URI模板
- dataweave - 如何比较两个数组并仅获取 Mule 4 中的共同值 - Dataweave
- pandas - 按数据框的列分组计算行数
- wordpress - 在联系表格 7 上使用图像作为单选按钮时不再需要该字段
- sparse-matrix - Eigen SparseQR 给出的结果与其他结果不同:bdcSVD、共轭梯度
- python - 如何在 django rest api 测试中的 GET 请求中发送数据
- python - 在 pyqt5 中使用 QSyntaxHighlighter 突出显示语法
- java - Java检查字符串是否仅包含英文键盘字母
- java - 我无法在 API <=22(使用 Android Studio 和 Unity)的设备中启动 Torch。为什么?