You need to open port 80 on your router to allow outside access to your TV's local IP address, the local IP usually defaults to 192.168.1.69 but yours may be different.
You'll need the public IP address for your router too, if you don't have a static IP address, you can look into setting up DynDNS to handle your public IP.
You'll also need to allow remote connections via a Pre-Shared Key (PSK) in the Network settings section. The Pre-Shared Key menu is located under Settings > Network > Home Network > IP control > Pre-shared Key. You must also allow authentication using a PSK under Settings > Network > Home Network > IP control > Authentication > Normal and Pre-shared Key.
I've tried to make the installation process as simple as possible but please create a new issue if you have any trouble getting the skill to work on your Amazon Echo or Echo Dot. Any and all feedback is greatly appreciated.
I'm not going to go into detail on how to set up an AWS account and how to create Users, Roles and Policies, there are already enough resources available via a quick Google search. Instead, the only thing you need to know about setting up your AWS account for use with this repo/library is that you need to create a local credentials file and store it in your computer user account's $HOME directory.
On Mac, just create a new credentials file with:
mkdir ~/.aws && touch ~/.aws/credentials
and add the following:
[default]
aws_access_key_id: <your_access_key_id>
aws_secret_access_key: <your_access_key_id>
aws_default_region: <your_default_region>Download and install node and npm if you haven't done so already.
# Clone the repository
git clone git@github.com:eoghanobrien/alexa-bravia-nodejs.git
# Install the node modules
npm install # or yarn
Duplicate the env.json.sample file and rename it to env.json. Open the file in your editor and update the variables.
FunctionName: The name of your Lambda function.Description: A description for your function (optional)Role: Your user role ARN.Timeout: The number of seconds before Lambda should timeout and stop processing your code (e.g.1=1 second)
region: The AWS region to host your function (e.g. us-east-1)
With your env.json file updated, you can now run the build tool. The build tool will copy all the required files into a directory called archive, zip up that directory and store the zip file under the dist directory. Note: The /dist/archive.zip file will be overwritten each time you run the build tool and the /archive/ directory will be deleted.
# Build the zip file to send to AWS Lambda
gulp build # or npm run build
With your zip file built, you can now deploy it to AWS Lambda.
# Deploy the zip file
gulp deploy # or npm run deploy
Next, login to your Lambda Management Console and click on the function you just created.
You'll see 3 buttons and 4 tabs. Click around and get comfortable.
Under the Code tab, you can add environment variables for:
APP_EMIT: You can use:tellor:tellWithCard.:tellwill not create a card in your companion app.:tellWithCardwill.APP_NAME: The name you want to see on your Alexa companion app cards, if you setAPP_EMITto:tellWithCard.APP_ID: I'll go into more detail on this later in theAlexa Installationsection.TV_IP: The public IP address of your router which has been set up to allow traffic on port80.TV_PSK: The Pre-shared Key you've set up on your TV underSettings > Network > Home Network > IP control > Pre-shared Key. You must also allow authentication using a PSK underSettings > Network > Home Network > IP control > Authentication > Normal and Pre-shared Key.
Under the Trigger tab, if you haven't already created an Alexa Skills Kit trigger, click Add Trigger to do that now. It will pop a modal window up where you can click the little square-with-grey-border in order to select a trigger. In the filter box, type Alexa Skills Kit and click. Then click Submit.
In order to create an Alexa Skill, you need to go to the Alexa Developer Console and sign in. Once you're signed in, click the Get Started button under the Alexa Skills Kit. Click Add a New Skill.
- Select
Custom Interaction ModelforSkill Type. - Select your language, I can verify it works with
English. - Enter the
Nameof your skill, I usedSony Bravia TV - Enter your invocation name, I used
TV. - Under
Global Fields, forAudioI selectedNo. - Hit
Next(It will save automatically).
- For the
Intent Schemafield, locate the fileintents.jsonin the repository under/assets/. Open it in your editor and copy the JSON data into the textarea field. - For the
Custom Slot Types, locate the fileslots.txtin the repository under/assets/. Open it in your editor and go back to the Skill creation page in your browser. You need to create 4 separate slots. Click on theAdd Slot Typebutton and enter the word in capital letters into theEnter Typefield (e.g.POWER). Then copy the values directly underneath the type into theEnter Valuesfield, each value should be on it's own line. Then hitSaveand rinse and repeat forAPPLICATION,INPUTandBUTTON. - For the
Sample Utterances, locate the fileutterances.txtin the repository under/assets/. Open it in your editor and copy the data into the textarea field. - Hit
Next.
- Under
English (U.S.)andService Endpoint Type, click the radio forAWS Lambda ARN, select yourLocation. Go back to theLambda Management Consoleand locate your Lambda function from earlier. YourARNshould be in the top right hand corner of the page. Copy that and paste it into the text field for theLocationyou selected. (e.g. North America) - Under
Account Linking, leave that set toNo. - Hit
Next.
Testing in this area is optional but if you want to try out an example Request, follow these steps.
- Go back to the
Skill Informationsection and copy yourApplication Id. - Go to the
Lambda Management Consoleand add a new environment variable with keyAPP_IDand paste the id as the value. - While you're here, why not also set environment variables for
TV_IP,TV_PSKandTV_PORT. You should have recorded that information as part of the earlier instructions. - Under
Service Simulator > Text > Enter Utterance, enterto power on.
Please don't publish my work under your own name. Feel free to fill this section out to see what it looks like in the companion app. I've provided two sample images:
/assets/bravia-108.png
/assets/bravia-512.png
Again, please don't publish my work under your own name.
I'd love to make a configuration page to store the IP address and Port of the TV and also the Pre-shared Key but I haven't found a way to do that without setting up an entire separate web service and ain't nobody got time for that. It also opens up a whole myriad of issues around security, privacy, terms of use, support and certification which I really have no intention of dealing with for a fun little side project.
- Alexa, open|start|launch TV
- Alexa, tell|ask TV to power on|off
- Alexa, tell|ask TV to turn on|off
- Alexa, tell|ask TV to set volume to {number}
- Alexa, tell|ask TV to change volume to {number}
- Alexa, ask|tell TV [to] mute
- Alexa, ask|tell TV [to] turn off volume
- Alexa, ask|tell TV [to] turn off sound
- Alexa, ask|tell TV to open {application}
- Alexa, ask|tell TV to change input to {input}
- Alexa, ask|tell TV to change input to HDMI {number}
- Alexa, ask|tell TV to hit {button}
- Alexa, ask|tell TV to press {button}