Control your webOS powered LG TV with amazon's alexa. This is a small DIY smart home project born out of lazyness and curiosity. It currently supports English and German invocations to control your device.
First of all the setup of this skill does require some amount of developer knowledge, as I am not able to cover everything here. This project consists of a NodeJS HTTP/S webserver in your local network (but has to be reachable by Amazons ASK Services). It handles incoming requests from Alexa and locally communicates with your LG TV.
Create your own Alexa app in Amazons developer center (uses new interaction model).
myname
to do something). It defaults to lgtv-remote
, however the model Invocation name may only contain alphabetic characters, apostrophes, periods and spaces.speechAssets/intentSchema.json
file, then click Save Model
.APP_IDS
(e.g. netflix, hulu, live, etc.) and INPUT_IDS
(e.g. hdmi1, hdmi2), then click Save Model
.Endpoint
* As this skill does boot up an HTTP/S server, that is what we want to use.
https://<id>.ngrok.io/lgtv-remote
to reflect calling of the app. Similarly if using heroku or AWS, would need to specify the lgtv-remote
application endpoint to enable Alexa to call this app. My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority
.Install all dependencies with npm install
.
Configure your environment. First cp .env.example .env
, then manipulate the values in .env
.
en
for English or de
for German. By changing the language in this environment variable, all intentions and invocations will be in the selected language. Also when running npm run docs
, this variable will generate new speechAssets in the selected language. Run the app with npm run start
.
Make sure the service connect's to your TV correctly (if it is turned on of course). Then check if the webserver is reachable from Amazon's ASK. It HAS TO BE using HTTPS. You can test connectivty through Amazon's developer center.
Make sure you call them from project root. Instead of npm
you can use yarn
of course. For all commands check the scripts
section in package.json
.
npm run start
builds and runs the app
npm run docs
builds the app and generates the speechAssets
Once I ensured the application works locally, I deployed on a Heroku server to have running in the background (could have used AWS, Google, etc). A few notes on deploying remotely:
PORT=4001
you'll need to forward all requests from Port=4001 to port 3000 on the IP address of your LG TV on your local network. YARN_PRODUCTION
to false
. Don't forget to set all other variables like TV_SOCKET
and TV_MAC
, otherwise your application running remotely won't find your TV.