From b93c5160b2bd4963f054637c903ee81335697689 Mon Sep 17 00:00:00 2001 From: mbalduccini Date: Sat, 19 Dec 2020 15:26:38 -0500 Subject: [PATCH 1/7] Update alexa-remote-routine.html Support for textCommand added following the approach from https://github.com/thorsten-gehrig/alexa-remote-control/blob/master/alexa_remote_control.sh --- nodes/alexa-remote-routine.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nodes/alexa-remote-routine.html b/nodes/alexa-remote-routine.html index a5e0348..b662a1c 100644 --- a/nodes/alexa-remote-routine.html +++ b/nodes/alexa-remote-routine.html @@ -886,6 +886,7 @@

References

const options = [ ['speak', ' Speak'], // play ['speakAtVolume', ' Speak At Volume'], + ['textCommand', ' Text Command'], // bolt ['wait', ' Wait'], // clock-o ['stop', ' Stop'], // stop ['prompt', ' Prompt'], // commenting @@ -1028,6 +1029,15 @@

References

return () => ({ type: type.arSelect('value') }); } groups.right.speakAtVolume = groups.right.speak; + groups.right.textCommand = function(data) { + data = template(data, { text: { type: 'str', value: 'Hello from Alexa Remote!'}}); + const input = arTypedInput(data.text, ['str']).appendTo(this); + return () => ({ text: input.arTypedInput('data') }); + //data = template(data, { type: 'regular' }); + //const type = arSelect(data.type, ['regular', ['ssml', 'SSML'], 'announcement']).appendTo(this); + //channel.type = type; + //return () => ({ type: type.arSelect('value') }); + } groups.right.wait = function(data) { data = template(data, { time: { type: 'num', value: '1' }}); const type = arTypedInput(data.time, ['num']).appendTo(this); @@ -1242,6 +1252,7 @@

References

devices: devices.arTypedInputOrInputList('data'), }); } + groups.bottom.textCommand = common.bottom.group.deviceList(false); groups.bottom.stop = common.bottom.group.deviceList(true); groups.bottom.prompt = common.bottom.group.deviceList(false); groups.bottom.phrase = common.bottom.group.deviceList(false); @@ -1450,4 +1461,4 @@

References

console.log('saved', this.routineNode); }, }); - \ No newline at end of file + From 18917d894efb389cc71f0d70c76c7316ba86963f Mon Sep 17 00:00:00 2001 From: mbalduccini Date: Sat, 19 Dec 2020 15:28:40 -0500 Subject: [PATCH 2/7] Update alexa-remote-routine.js Support for textCommand added following the approach from https://github.com/thorsten-gehrig/alexa-remote-control/blob/master/alexa_remote_control.sh --- nodes/alexa-remote-routine.js | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/nodes/alexa-remote-routine.js b/nodes/alexa-remote-routine.js index 2ffbb61..b633e6b 100644 --- a/nodes/alexa-remote-routine.js +++ b/nodes/alexa-remote-routine.js @@ -269,6 +269,42 @@ module.exports = function (RED) { }); } } + case 'textCommand': { + if (!Array.isArray(node.payload.devices)) { + const single = node.payload.devices || node.payload.device; + node.payload.devices = single ? [single] : []; + } + checkPayload({ text: '' }); + const devices = findAll(node.payload.devices); + + if (devices.length === 0) return undefined; + if (devices.length === 1) return { + '@type': 'com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode', + type: 'Alexa.TextCommand', + skillId: 'amzn1.ask.1p.tellalexa', + operationPayload: { + deviceType: devices[0].deviceType, + deviceSerialNumber: devices[0].serialNumber, + locale: locale, + customerId: devices[0].deviceOwnerCustomerId, + text: node.payload.text + } + }; + + return await nativizeNode({ + type: 'node', + payload: { + type: 'parallel', + children: devices.map(device => ({ + type: 'textCommand', + payload: { + text: node.payload.text, + device: device, + } + })) + } + }); + } case 'stop': { if (!Array.isArray(node.payload.devices)) node.payload.devices = [node.payload.devices || node.payload.device]; checkPayload({ devices: [] }); @@ -663,4 +699,4 @@ module.exports = function (RED) { }); } RED.nodes.registerType("alexa-remote-routine", AlexaRemoteRoutine); -}; \ No newline at end of file +}; From 24fbd918e60774a7ec12a6bb68ba9b0da5616ee5 Mon Sep 17 00:00:00 2001 From: mbalduccini Date: Sat, 19 Dec 2020 15:34:41 -0500 Subject: [PATCH 3/7] Update CHANGELOG.md More changes related to textCommand extension --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab10d66..27dd272 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- **3.10.5** + - added *textCommand* - **3.10.4** - update dependency alexa-remote2 to 3.3.1 - **3.10.3** From f7389583a0de27c6685143e80fe5f37c826cabba Mon Sep 17 00:00:00 2001 From: mbalduccini Date: Sat, 19 Dec 2020 15:35:35 -0500 Subject: [PATCH 4/7] Update package.json More changes related to textCommand extension --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4d9277b..25ca916 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-alexa-remote2", - "version": "3.10.4", + "version": "3.10.5", "author": { "name": "586837r", "email": "586837r@gmail.com" From 0a35d04dd4552894a4d6a413cd6e9a7cdcd5df46 Mon Sep 17 00:00:00 2001 From: mbalduccini Date: Sat, 19 Dec 2020 15:36:19 -0500 Subject: [PATCH 5/7] Update package-lock.json More changes related to textCommand extension --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 10a5dde..726bee0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-alexa-remote2", - "version": "3.10.4", + "version": "3.10.5", "lockfileVersion": 1, "requires": true, "dependencies": { From 15cf25328def92cc7629ebdf994a34a41613c579 Mon Sep 17 00:00:00 2001 From: mbalduccini Date: Sat, 19 Dec 2020 15:40:48 -0500 Subject: [PATCH 6/7] Update alexa-remote-routine.html textCommand support --- nodes/alexa-remote-routine.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nodes/alexa-remote-routine.html b/nodes/alexa-remote-routine.html index b662a1c..f142683 100644 --- a/nodes/alexa-remote-routine.html +++ b/nodes/alexa-remote-routine.html @@ -34,6 +34,9 @@

Info

Speak At Volume or Volume with the Add mode can only change the volume if the echo has recently been active playing music!

+
  • +

    Text Command allows for sending anything you would otherwise say to Alexa (more details here)

    +
  • With the Custom option, you can feed in a routine node as js object for completely dynamic routines. The objects can look like this:

    From 75d2707bf23951698e854044e640a69d76c0a08b Mon Sep 17 00:00:00 2001 From: mbalduccini Date: Sat, 19 Dec 2020 15:42:35 -0500 Subject: [PATCH 7/7] Update CHANGELOG.md Details added --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27dd272..268719b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ - **3.10.5** - - added *textCommand* + - added *textCommand* -- see https://github.com/thorsten-gehrig/alexa-remote-control - **3.10.4** - update dependency alexa-remote2 to 3.3.1 - **3.10.3**