How to Add Alexa to Your Smart Mirror

An intelligent mirror with a reflective Amazon echo. Josh Hendrickson

If you builds a smart mirroryou already have convenient access to calendars, weather and news. But you can do more than that! The Magic Mirror software allows you to add modules for additional features, such as Alexa for voice control.

Other developers are creating these modules. Options range from useful, like Alexa or presence detection (via a camera or passive infrared sensor), to entertaining, like snowflakes and Spotify playback information.

We recommend mmm-great-alexa as it seems to be well maintained by an active developer, although there are other Alexa modules for Magic Mirror software.

If you prefer to install Google Assistant, Google offers a complete tutorial to install Wizard on a Raspberry Pi, including steps, images and download links. Although there are some Magic Mirror modules for Google Assistant, our investigation revealed that the modules were problematic, often causing a crash or hiding mirror information. If you want the simplest configuration, we recommend adding the Google AIY Kit and using his specific tutorial.

To install most modules, you need to follow some basic steps:

  1. Download module code from GitHub
  2. Configure module-specific options
  3. Add the module to the mirror configuration

Depending on the module, steps two and three may be more or less involved. Setting up Alexa requires more configuration than adding snowflakes, for example. In addition, this particular Alexa module requires the installation of additional software (dependencies) before downloading the module.

RELATED: How to build your own futuristic smart mirror

The material you will need

A voice kit Google AIY
Google

This guide assumes that you have already created a Smart Mirror. If this is not the case, start with this, but keep in mind the additional elements listed here in your cost and space considerations.

  • Completed Smart Mirror
  • Microphone
  • Speaker

For the microphone and the speaker, we recommend the original Google Voice Kit AIY. At $ 16, you'll have trouble finding a cheaper microphone / speaker combination. You do not necessarily need to use the supplied cardboard box; It may be more effective to keep the components out of the way and to move the microphone and speaker out of the mirror.

A second version of Google Voice Kit AIY available, but it is more expensive and includes a Raspberry Pi Zero, which is not powerful enough to run waking words or Magic Mirror software. You must ignore it.

Plug in your speaker and microphone and you're ready to install the Alexa module. If you use the Google AIY kit, just follow its instructions. assembly guide to connect the microphone and speaker components.

Installation of module dependencies

Before you can download and configure mmm-awesome-alexa, you must install some dependencies on which the module is based. It is always a good idea to update your Raspberry Pi before installing anything else. On your Raspberry Pi, first execute this command:

sudo apt update & sudo apt upgrade

Once your Raspberry Pi is up to date, run the following commands one by one:

sudo apt-get install sox libsox-fmt-all
sudo apt-get install swig3.0 python-pyaudio python3-pyaudio sox
pip install pyaudio
sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg libav-tools
sudo apt-get install libatlas-base-dev

Each command installs a dependency and it is necessary to execute it. Just run a command, wait for the download and installation to complete, and then run the next command.

Downloading the module code

The first step to add a module to the Magic Mirror is to download the module's Github code. To do this, you must connect to Raspberry Pi, open a terminal and change the directory in which the modules are stored. Then you will use a download command to extract the code from Github If you have shell accessyou can do all this from a distance.

Once you have an open terminal, type the following:

cd ~ / MagicMirror / modules

This command allows you to access the working directory of the Magic Mirror software module folder. Whenever you download a new module, you will want to be here to organize everything. The next step is to download the software from Github with this command:

clone of git https://github.com/dolanmiu/MMM-awesome-alexa.git

When it's done, change the directory in the module with the following command:

cd MMM-awesome-alexa

The Alexa module requires some additional dependencies to work properly. Run this command to install them:

npm install --only = prod

Now, change the directories in the newly created node_modules folder:

cd node_modules

Delete the snowboy folder added to previous commands. We need a newer version of snowboy:

snowboy rm -rf

Then we will download the latest version of snowboy with the following command:

git clone https://github.com/Kitt-AI/snowboy.git

Before continuing, change directory in the new snowboy folder.

snowboy cd

We now need to delete the node_modules folder and install additional dependencies. It is important to stay in the snowboy folder for these steps. do not change directory. Run the following commands one by one:

rm -rf node_modules
npm install nan --save
npm install node-pre-gyp@0.12.0 --save
npm install
npm run prepublish
npm install --save-dev electron-rebuild
npm install nan
./node_modules/.bin/electron-rebuild

Now the module is fully downloaded and installed.

Alexa module configuration

Configuration Help Dialog for MMM-awesome-alexa

Now that the mmm-awesome-alexa module is installed, we need to configure it. The first step is to change the directory to the root of the module. In the terminal, type the following command, and then press ENTER:

cd ~ / MagicMirror / modules / MMM-awesome-alexa

This Alexa module has a configuration wizard; we want to run that. In terminal type:

npm run config-helper

You will see a prompt asking for a client ID. Since you are essentially configuring a custom echo, you need to open a browser and access the Alexa developer site. Then log in with your Amazon account.

Once connected, click on the "Get Started" button. You create a device, so click on "Products" and then "Create a product".

Alexa developer dialog with box around the Products option.

On the next screen, give your product a name and a product ID. We suggest "Magic_Mirror_Alexa" for the name and "YourFirstName_MM_Alexa" for the product ID. Select Smart Home for the category and enable Handsfree and Far Field options. You will see a series of questions yes or no, select "No" for all, then click "Next".

On the security profile screen, click on "Create a new profile". Use the same name for your security profile as for the product ID. Then type the description that you want, and then click Next.

Check the agreement and click Finish.

Click on the product you just created and then on the security profile. A client ID and a client secret should be displayed.

In the returned URL entry type allowed:
https://magic-mirror-avs.github.io/Alexa-Web-Helper/authresponse

Then click the Add button. Scroll down the list and click on the update box to finish adding the URL.

In the terminal you will see a prompt for the customer ID. Copy the client ID from the browser, paste it into the terminal, and press Enter. Now the terminal will ask you for a client secret. Return to the browser, copy the client's secret, then paste it into Terminal and press Enter.

When prompted to enter the device ID, enter the name you created above as the product ID (Magic_Mirror_Alexa in our example).

When you are prompted for a return URL, type the following command and press Enter:

https://magic-mirror-avs.github.io/Alexa-Web-Helper/authresponse

The terminal will display a custom built link. Copy it and paste it into your browser. Then sign in with your Amazon account, if prompted. Click Allow on the next screen.

Alexa prompts service permissions with a box around the allow button.

You will see an error on the browser, but do not worry! This is planned. Scroll through the URL of the error page and look for the section "Code = xxxxxx".

URL indicating the code of the Alexa device.

Copy the letters and numbers that appear between "code =" and "& scope" and paste them into the terminal. Press Enter when done.

When asked if you want to generate the MagicMirror configuration, type Y and press Enter.

You will be asked which awakening word to use. Alexa is the default selection, press Enter.

Answer no to use the lite mode and the visualization.

The configuration wizard will generate the information of your module. It will look like this:

{
module: "MMM-awesome-alexa",
position: "bottom_bar",
config: {
wakeWord: "Alexa",
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
deviceId: "YOUR_DEVICE_ID",
refreshToken: "YOUR_REFRESH_TOKEN",
lite: false,
isSpeechVisualizationEnabled: false
}
}

Module code generated automatically.

Copy these lines. We need to add them to the Magic Mirror configuration.

Add the Alexa module to the Magic Mirror configuration

Then change the directory in the Magic Mirror configuration folder with the following command:

cd ~ / MagicMirror / config

And open the config.js file with the nano command:

nano config.js

Just after the first instance of } (which is the end of the module), press Enter to create a blank line before the next { input (which is the beginning of a new module).

module code, with a new line inserted after}, and before {

On the new blank line that you created, paste the module code from the steps of the setup wizard. The automatically generated code has an error. you will also have to type a comma after the last hook so that your module ends with }

inserted module code with a comma added after the final hook

Use Ctrl + x to close the file. When prompted, type "y" to confirm the backup and press Enter to keep the same file name.

The module is finished. To restart your Magic Mirror software with the module in place, type pm2 restart mm and the Magic Mirror software will restart. Alexa should now work on your magic mirror.

This is one of the most complicated modules you can configure for the Magic Mirror. But for the other modules, the basic steps are the same, download the code, configure the module-specific options, add the module to the configuration. You can add snowflakes to your mirror, or motion detection, or even display your Google Photos.

Advertisements

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.