Closed StarfighterJ closed 6 years ago
Congrats on getting the code working and sending commands to it from Alexa. From the output it looks like you sent a turn off tv command, followed by a turn on tv command? I'm assuming if the TV is on and you send mute commands or open Netflix, etc it should work as well. As long as ngrok is running you will keep the same endpoint, if you closed it and a new ngrok session is opened, you'll need to update the custom Alexa skill with the new endpoint. To avoid this issue I moved my instance to the cloud on Heroku, which is where I assume you'll want to run this from (or AWS...).
The original code calls module lgtv2 to handle all the functions with the TV including the storing of the keyfile, In the node_modules directory you should see some of that code there including the pairing.json file along with the code that actually creates the keyFile. Is this what you meant?
One of the limitations of the original code was that the TV needs to be on for the program to connect using the ip address in the configuration (otherwise you get the can't connect error you previously shared). I've tried playing around with different wake on lan modules so that it doesn't need to be on and can be awoken remotely, however I've had limited success in making that work 100%.
voydz (felix), made some suggestions in the code to implement a better connector but I haven't gotten around to testing and implementing such a feature, if you have suggestions on making the code better, please do so and I can incorporate into my fork or even in the original code. The reason I forked his code was because his version was in german, after you wrote I updated my code to handle localization for German or English and suggested a pull request. This was really a side project to test somethings on the LG, not ultimately sure what you want to do with this API.
All seems fine until I ask to turn TV on then I get the : Sending magic packet to XX:XX:XX:XX:XX:XX with IP=XXX.XX.XXX.XXX. All's fine. Your computer is awakening right now... then nothing works. I do not know why it is doing this above I think I want to move the instance to the Cloud on Heroku for now Like you did for now but want do you mean by instance and what and how goes up there.
LOL my main objective was to turn the TV on I hope you can figure that out. But my primary objective was to have a Alexa Skill run the whole or part of my LG Smart tv. FYI I install a APP on my tablet call LG WFI remote, it actually found my TV and Paired it and it runs real good. So if it could do that So can Alexa. I was on voydz start to change all the German to English and he said you were doing that LOL that is how I found you. Any way going to play with ngrok some more. and I need help on Heroku. Thank you all you help
I probably broke the connector when I swapped out the wake on lan function from wake_on_lan to wake-on-lan. My router can turn on the tv from the interface consistently, so it's likely just the code in connector.js. if I were to guess. If I have some time I'll play around with it and see what I come up with, voydz did make it clear that the tv has to be on for this to all work, but I'm sure we can make the code better. For now updated my for to voydz's original code and as I have some time I'll review again.
As for Heroku, it should be fairly easy to get it up and running now that you have it working locally. You just need to push your code from your local repository to Heroku. They use a version of Git, so you if you are familiar you can just push to your Heroku app and it should install the dependencies based on the packages.json and yarn file. Instead of having an .env file, you set those parameters in the dashboard for your app. Once your app is running, you can get an endpoint that can be used by your custom alexa app. Let me know if you get stuck...
Yeah now I am getting this response on the new code now when i ask TV to turn on and I have to end batch file, and do another npm run start: C:\Users\TEST\Downloads\alexa-lgtv-remote-master\alexa-lgtv-remote-master>npm run start
alexa-lgtv-remote@1.0.0 start C:\Users\TEST\Downloads\alexa-lgtv-remote-master\alexa-lgtv-remote-master gulp build && node dist/index.js
[15:02:40] Using gulpfile ~\Downloads\alexa-lgtv-remote-master\alexa-lgtv-remote-master\gulpfile.js [15:02:40] Starting 'build'... [15:02:40] Starting 'lint'... [15:02:48] Finished 'lint' after 8.29 s [15:02:48] Starting 'builder'... [15:02:49] Finished 'builder' after 620 ms [15:02:49] Finished 'build' after 8.91 s Loaded "en" Translations successfully. alexa-lgtv-remote listening on port 3000! Fire of request 'ssap://audio/setMute' with payload: { mute: true } Fire of request 'ssap://audio/setMute' with payload: { mute: false } Fire of request 'ssap://system/turnOff' with payload: undefined Executing turnOff 1000 Executing turnOn { Error: connect ETIMEDOUT 174.64.137.102:3000 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1174:14) errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect', address: '174.64.137.102', port: 3000 }
Also this is what I get in Alexa test: ask lg tv mute
OK. ask lg tv un mute
OK. ask lg tv turn off
There is a problem with the device. ask lg tv trun on
The requested skill took too long to respond ask lg tv netflix
Disconnected.
Also there is a Major problem with app_ids and input_ids I can get Netflix to work some times by this ask lg tv app_ids netflix, but none the rest like amazon, hula, and more. on node.jp promt it is ask this: try to resolve app amazon Starting: lovefilm.de Fire of request 'ssap://system.launcher/launch' with payload: { id: 'lovefilm.de' } Not sure but I think lovefilm.de is German.
input_ids like ps3, ps4, satellite is a big no go.
Just a thought it might be a good idea to get rid of the _ids to make shorter.
for the app_ids, did you add them to your model, similar to the below screen shot?
In the model the sample utterances should be start the app, open the app, open the application, etc so the test in your example would be ask lg tv start the app hulu and it should open Hulu. Let me know if you don't see that...
Yes I did add to APP_IDS.
Work on hula, but does not Like Amazon: try to resolve app amazon Starting: lovefilm.de Fire of request 'ssap://system.launcher/launch' with payload: { id: 'lovefilm.de' }
I think there is a Problem with id: 'lovefilm.de' } Also get this on crackle try to resolve app crackle Unhandled exception: app id not known.
and I can't get input to work at all
"name": "INPUT_IDS", "values": [ { "name": { "value": "screen share" } }, { "name": { "value": "dvd player" } }, { "name": { "value": "ps3" } }, { "name": { "value": "roku" } }, { "name": { "value": "vizio" } }, { "name": { "value": "satelite" } }, { "name": { "value": "live tv"
that looks like an issue with the original lookup file that references the lovefilm.de site. Can you update the lookup.js file in the src/api folder in your local repo and change the amazon entry to "amazon" instead of the german site and retest?
I added various inputs there but hadn't gotten to testing them (I don't think). I'll play around with that this weekend.
The Amazon trick worked in the lookup.js file I am also going to add more. not sure how to provide that to you, but as a copy and paste. I'll do that after I test them all.
You can submit a pull request via GitHub and I can review and incorporate into my fork. Or as you mention, just open a new issue with your proposed changes and I can include in my next push to the repo. Thanks for the testing, I'll get to Inputs shortly to see what is going on with the different HDMIs, if you look at your input_id entries, these are not in the lookup table, so that could be the reason for the problems (though live TV should have worked as I'm sure I tried that when I added to my forked version).
I am getting this after about 10 mins in to testing I am almost there. (See Blow) Also when turning on tv getting a "Requested Skill took to long to respond" it does turn on tv but, it produces the below result. When you said this: " Once you’ve accepted the request on tv, it stores the authorization locally and you shouldn’t get again (unless you delete the key on your pc)." What file and where would this hide on my PC?. One more thing now that I have this set up on ngrok will it stay there or do I have to do the whole process again?
C:\Users\TEST\Downloads\alexa-lgtv-remote-master\alexa-lgtv-remote-master>npm run start
[16:17:20] Using gulpfile ~\Downloads\alexa-lgtv-remote-master\alexa-lgtv-remote-master\gulpfile.js [16:17:20] Starting 'build'... [16:17:20] Starting 'lint'... [16:17:28] Finished 'lint' after 8.19 s [16:17:28] Starting 'builder'... [16:17:29] Finished 'builder' after 600 ms [16:17:29] Finished 'build' after 8.8 s Loaded "en" Translations successfully. alexa-lgtv-remote listening on port 3000! Fire of request 'ssap://system/turnOff' with payload: undefined Executing turnOff 1000 Sending magic packet to XX:XX:XX:XX:XX:XX with IP=XXX.XX.XXX.XXX. All's fine. Your computer is awakening right now...