Closed StarfighterJ closed 6 years ago
OK, so good news is that now the program is running and can be called by the Amazon Skill. If you are not getting a timeout error, it means that it is connecting to the tv locally. I believe the first time you invoke one of the commands you should see the prompt on the TV.
Have you created the custom skill on Amazon and are ready to test it? For example, if you follow my instructions, you should have created an invocation name, added some slots for intentions, pasted the schema that goes into the JSON model, and designated an endpoint.
From the test tab, you can see if the endpoint is reachable and start sending commands. I suggest a simple mute command and you can see if the endpoint is reachable from Amazon's servers. I started with an ngrok endpoint to make sure that my local machine was working before pushing to the cloud.
For AWS, you would need to send the src and main directories and ensure that it compiles on the server with all dependencies, etc. Depending on your configuration it might require setting up environment variables for the instance or if you are using a remote server that's always running, you just need to make sure that the .env file points to your external ip address for your internet provider (please share details as to what you're intending).
I am using a Windows 10 PC to do this. I finally got the accept Prompt on TV after Running npm run start and Changing internal IP to my external ip address form my internet provider. FYI I did not get the accept Prompt after running it again even after turn TV off and back on dies it stay paired?
Am I suppose to do something after that like add device in the Alexa app if so that did not find?
On AWS Lambda what runtime should I use right now I am using Node.js4.3 any Higher I think I need to Convert the SCR fold Files to .js I am not sure what you mean by a remote server always running and running what Program would it be running. My intention is to make this work Like a Alexa Skill using AWS Lambda. I helped doing a Alexa Skill for DirectTV. that works great now.
I did create on the custom skill on Amazon that was successful. I ran the test this is what I got: mute (This worked but the rest did not**) turn off tv
You don't have any Smart Home devices, to get started, go to the Smart Home section of the Alexa App. mute tv trun on tv
Sorry, I'm not sure. turn on mute
Sorry, what device?^
This is to whole event Start with npm install I am using Node.js : C:\Users\TEST\Downloads\alexa-lgtv-remote-master (1)\alexa-lgtv-remote-master>npm install npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.0 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.0: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
added 113 packages from 75 contributors in 6.466s
C:\Users\TEST\Downloads\alexa-lgtv-remote-master (1)\alexa-lgtv-remote-master>npm run start
alexa-lgtv-remote@1.0.0 start C:\Users\TEST\Downloads\alexa-lgtv-remote-master (1)\alexa-lgtv-remote-master gulp build && node dist/index.js
[17:18:53] Using gulpfile ~\Downloads\alexa-lgtv-remote-master (1)\alexa-lgtv-remote-master\gulpfile.js [17:18:53] Starting 'build'... [17:18:53] Starting 'lint'... [17:19:01] Finished 'lint' after 7.96 s [17:19:01] Starting 'builder'... [17:19:01] Finished 'builder' after 575 ms [17:19:01] Finished 'build' after 8.54 s alexa-lgtv-remote listening on port 3000! events.js:165 throw er; // Unhandled 'error' event ^
Error: connect ECONNREFUSED 127.0.0.1:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14)
Emitted 'error' event at:
at Socket.socketErrorListener (_http_client.js:395:9)
at Socket.emit (events.js:180:13)
at emitErrorNT (internal/streams/destroy.js:64:8)
at process._tickCallback (internal/process/next_tick.js:178:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! alexa-lgtv-remote@1.0.0 start: gulp build && node dist/index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the alexa-lgtv-remote@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\TEST\AppData\Roaming\npm-cache_logs\2018-04-24T21_34_03_640Z-debug.log
So you created a skill, let's assume the invocation name was "el gee", in the test tab you would type
ask el gee to mute tv
.
To turn off tv you would similarly type ask el gee to turn off tv
. My experience with the invocation name is to be careful not to pick a reserved word, so if you pick something like "tv" and say "ask tv to mute tv" it might not respond as you would expect.
The documentation for AWS lambda is here but to be honest I haven't deployed this app using AWS lambda I deployed it on a Heroku server since it was free. I'm also on Windows and didn't want to mess with making sure the node_module versions were correct when zipping up the files.
You might consider checking out this documentation that walks through how to convert the nodejs app into a serverless app.
Good luck!
Thank you I am going to try and do it your way first on Heroku Server ,but what files go up there? and what would my Endpoint be? Also if all the files go up on the Server do I run the" npm install and npm run start on the server side?
I suggest you confirm you can get the server running locally on your windows machine first to ensure the code is doing everything you want it to before pushing the application to a Heroku server (or AWS). If you've already done this apologize, as it's not clear if you've gotten the application running and working.
When building locally, you will need an endpoint that the AWS server can access that is using https. I used ngrok for that, which if you are running the app on port 3000, you can run
ngrok http 3000
and it will provide an endpoint that you can put into the Alexa skill to test.
When you build on Heroku, you can basically push your git repository directly to Heroku and they will provide you an endpoint that you can use for the Alexa skill. On Heroku you can set your environment variables (so you don't publish the .env to the repository) and you'll need to open up your router to accept those incoming calls.
Will closeout this item, let me know if you need anything else
Hi and thank you for getting back to me. I did not get the prompt you on the TV to accept commands from this code the first time your run it. The prefix on the ip address with ws:// Did work on getting rid of the first error. but got another error about ten minutes later I did Port Forward my IP to 3000 Below is what I am getting: C:\Users\TEST\Downloads\alexa-lgtv-remote-master (1)\alexa-lgtv-remote-master>npm run start
[14:56:30] Using gulpfile ~\Downloads\alexa-lgtv-remote-master (1)\alexa-lgtv-remote-master\gulpfile.js [14:56:30] Starting 'build'... [14:56:30] Starting 'lint'... [14:57:00] Finished 'lint' after 31 s [14:57:00] Starting 'builder'... [14:57:01] Finished 'builder' after 607 ms [14:57:01] Finished 'build' after 31 s alexa-lgtv-remote listening on port 3000!
events.js:165 throw er; // Unhandled 'error' event ^
Error: connect ECONNREFUSED 127.0.0.1:80 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14) Emitted 'error' event at: at Socket.socketErrorListener (_http_client.js:395:9) at Socket.emit (events.js:180:13) at emitErrorNT (internal/streams/destroy.js:64:8) at process._tickCallback (internal/process/next_tick.js:178:19) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! alexa-lgtv-remote@1.0.0 start:
gulp build && node dist/index.js
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the alexa-lgtv-remote@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\TEST\AppData\Roaming\npm-cache_logs\2018-04-24T19_12_03_347Z-debug.log
Here is what I got in that Debug.log 0 info it worked if it ends with ok 1 verbose cli [ 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Users\TEST\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'start' ] 2 info using npm@5.8.0 3 info using node@v9.11.1 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle alexa-lgtv-remote@1.0.0~prestart: alexa-lgtv-remote@1.0.0 6 info lifecycle alexa-lgtv-remote@1.0.0~start: alexa-lgtv-remote@1.0.0 7 verbose lifecycle alexa-lgtv-remote@1.0.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle alexa-lgtv-remote@1.0.0~start: PATH: C:\Users\TEST\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\TEST\Downloads\alexa-lgtv-remote-master (1)\alexa-lgtv-remote-master\node_modules.bin;C:\Users\TEST\AppData\Roaming\npm;C:\Program Files\nodejs\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\nodejs\;C:\Users\TEST\AppData\Local\Microsoft\WindowsApps;C:\Users\TEST\AppData\Roaming\npm 9 verbose lifecycle alexa-lgtv-remote@1.0.0~start: CWD: C:\Users\TEST\Downloads\alexa-lgtv-remote-master (1)\alexa-lgtv-remote-master 10 silly lifecycle alexa-lgtv-remote@1.0.0~start: Args: [ '/d /s /c', 'gulp build && node dist/index.js' ] 11 silly lifecycle alexa-lgtv-remote@1.0.0~start: Returned: code: 1 signal: null 12 info lifecycle alexa-lgtv-remote@1.0.0~start: Failed to exec start script 13 verbose stack Error: alexa-lgtv-remote@1.0.0 start: (C:\Users\TEST\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:283:16)
13 verbose stack at EventEmitter.emit (events.js:180:13)
13 verbose stack at ChildProcess. (C:\Users\TEST\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:180:13)
13 verbose stack at maybeClose (internal/child_process.js:936:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid alexa-lgtv-remote@1.0.0
15 verbose cwd C:\Users\TEST\Downloads\alexa-lgtv-remote-master (1)\alexa-lgtv-remote-master
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\TEST\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "start"
18 verbose node v9.11.1
19 verbose npm v5.8.0
20 error code ELIFECYCLE
21 error errno 1
22 error alexa-lgtv-remote@1.0.0 start:
gulp build && node dist/index.js
13 verbose stack Exit status 1 13 verbose stack at EventEmitter.gulp build && node dist/index.js
22 error Exit status 1 23 error Failed at the alexa-lgtv-remote@1.0.0 start script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]My tv is a [LG] webOS TVUJ6570 (a 2017 model) Software Version 04.70.10
Also for AWS Lambda What part of the Program need to go up there Zipped I am guessing the contents in the SRC Folder. Any help on this Please Advise Thank you