Skip to content

Turn on your Xbox One using an Amazon Echo/Alexa.

Notifications You must be signed in to change notification settings

phpcodemonkey/alexa-xbox

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alexa-xbox

This is an application for use with Amazon Alexa in order to turn your Xbox on using your Amazon Echo or Echo Dot.

Install

When setting up an Alexa app, you can specify a secure URL where these files should be placed. The only file you will need to edit is to copy site/includes/.env-dist to your own file site/includes/.env file.

APP_ID=amzn1.ask.skill.12345678-1234-1234-1234-123456789123
APP_NAME="Xbox Control"

IP_ADDRESS=123.456.654.321 # Current public IP address
XBOX_LIVE_ID=ABCD1234ABCD1234 # Xbox -> Settings -> System -> Console Info -> Xbox Live device ID

Additionally, you will need to ensure the site/logs folder is writable by your web server. If you wish to have Slack integration, you can edit the .env entries with the relevant details:

SLACK_API_TOKEN=""
SLACK_CHANNEL="#log_alexa_xbox"

Finally, you'll need to have composer, the common PHP package manager, available and then to run composer install. Completing this will bring in the dependent libraries to site/vendor.

IP Address & Xbox Live device ID

For the app to connect to your Xbox, 3 things are required:

  1. Your router must forward port 5050 to your Xbox.
  2. As your Xbox will be turned on remotely, the public IP address for your Xbox is needed.
  3. The Xbox Live device ID. On your Xbox: All settings > System > Console Info > Xbox Live device ID.

Setting up Alexa

  1. Setup an account/Log in at https://developer.amazon.com/home.html

  2. Click on the Alexa tab

  3. Click on Alexa Skills Kit

  4. Click Add a New Skill

  5. Select Custom Skill and your language settings

  6. In the Skill Information tab, enter Name: Xbox Control and Invocation Name: xbox control (lowercase)

  7. Copy the Application Id to your .env file

  8. In the Interaction Model tab enter the following as your Intent Schema:

    {
      "intents": [
        {
          "intent": "XboxControl"
        }
      ]
    }
  9. In the Sample Utterances section enter (or other phrases you wish to use with the Intent Schema prefix):

    XboxControl on
    XboxControl turn on
    XboxControl power on
    XboxControl start
    XboxControl switch on
    XboxControl to turn on
    XboxControl to power on
    XboxControl to start
    XboxControl to switch on
    
  10. In the Configuration tab, pick https and enter the URL of your hosted codebase. (If you don't have an SSL certificate, take a look at EFF's Certbot to set one up)

  11. On the Test tab, ensure the Enabled toggle is set to This skill is enabled for testing on your account. Further down on this tab, there's a useful Service Simulator to allow you to test (and see the data passing back and forth).

  12. The Pubishing Information tab, you can add descriptions, example phrase and images to make things look as they should in your Alexa phone app. You do not, however, need to Submit for Certification for use for your own purposes - stay in test mode it will all work fine.

  13. On the Privacy & Compliance tab, check the Export Compliance statment.

  14. All other settings, in tabs, can be left as defaults.

  15. Click save and your Alexa skill will be ready to use, you can see it in your Alexa App under Skills > Your Skills > All Skills

  16. To invoke Alexa to turn your Xbox on, try phrases like Alexa, tell Xbox Control to turn on or similar variants as you set up in Sample Utterances.

Testing

It's probably a good idea to test the connection first, between the server that runs the app and your Xbox. To do this, you can simply set .env DEBUG to true so authentication requests from Alexa will be bypassed by this feature.

How it works

The first thing the app does, is check that the Xbox is not already running by pinging it. If it isn't, then it will attempt to send a magic packet to the Xbox. It will wait one second before pinging again to see if the packet was received and the Xbox turned on. Five attempts will be performed at turning the Xbox on. After the 5th failed attempt, it will generate data for Alexa asking you to try again (It's worth noting that turning the Xbox on this way immediately after you have turned it off doesn't always work. There is normally around 10-30 seconds of cool-off time before it will accept the WOL packet).

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%