Other developers create these modules. The options vary from the useful, like Alexa or presence detection (through a camera or Passive Infrared sensor), to the entertaining, like snowflakes and Spotify playback info.
We recommend mmm-awesome-alexa as it appears to be well maintained by an active developer, although there are other Alexa modules for the Magic Mirror software.
If you would prefer to install Google Assistant, Google offers a complete tutorial for installing Assistant on a Raspberry Pi, including steps, images, and download links. While a few Magic Mirror modules for Google Assistant exist, our investigation revealed the modules to be problematic, often crashing or covering the mirror information. If you want the most straightforward setup, we recommend adding the Google AIY kit and using its specific tutorial.
To install most modules, you’ll go through some basic steps:
Download the module code from GitHub Configure module-specific options 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 instance. Additionally, this particular Alexa module requires installing some additional software (dependencies) before downloading the module.
RELATED: How to Build Your Own Futuristic Smart Mirror
The Materials You’ll Need
This guide assumes you’ve already created a Smart Mirror. If you haven’t yet, start there but keep in mind the extra materials listed here in your costs and space considerations.
Completed Smart Mirror Microphone Speaker
For the microphone and speaker, we recommend the original Google AIY Voice Kit. At $16, you’ll be hard-pressed to find a cheaper microphone and speaker combination. You don’t necessarily need to use the included cardboard box; it may be more effective to leave the components out and run the microphone and speaker outside the mirror.
A second version of the Google AIY Voice Kit is available, but it’s more expensive and includes a Raspberry Pi Zero, which isn’t powerful enough to run wake words or the Magic Mirror software, so you should skip it.
Connect your speaker and microphone, and you’re ready to install the Alexa module. If you’re using the Google AIY kit, just follow its assembly guide for connecting the microphone and speaker components.
Installing Module Dependencies
Before you can download and configure mmm-awesome-alexa, you need to install a few dependencies the module relies on. It’s always a good idea to update your Raspberry Pi before trying to install anything else. On your Raspberry Pi, start by running this command:
Once your Raspberry Pi is up to date, run the following commands one by one:
Each command installs a dependency, and they’re all necessary to run. Just run a command, wait for the download and install to finish, then run the next command.
Downloading the Module Code
The first step to adding any module for the Magic Mirror is to download the module’s code Github. To do this, you’ll need to log into the Raspberry Pi, open terminal, and change directory to where modules are stored. Then you’ll use a download command to pull the code from Github If you have shell access, you can do all of this remotely.
Once you have a terminal open, type the following:
This command moves you to the working directory of the modules folder for the Magic Mirror software. Anytime you download a new module, you’ll want to be here to keep everything organized. The next step is to download the software from Github with this command:
When it finishes, change directories into the module with the following command:
The Alexa module requires a few additional dependencies to work correctly. Run this command to install them:
Now, change directories into the newly created node_modules folder:
Delete the snowboy folder the previous commands added. We need a newer version of snowboy:
Next, we’ll download the latest version of snowboy with the following command:
Before we continue, change directory to the new snowboy folder.
Now we need to remove the node_modules folder and install some additional dependencies. It’s important that you stay inside the snowboy folder for these steps; don’t change directories. Run the following commands one by one:
Now the module is fully downloaded and installed.
Configuring the Alexa Module
Now that the mmm-awesome-alexa module is installed, we need to configure it. The first step is to change directories to the root of the module. In terminal type the following command and then hit Enter:
This Alexa module has a configuration helper; we want to run that. In terminal type:
Once signed in, click on the “Get Started” button. You’re creating a device, so click “Products” and click “Create Product.”
On the next screen, give your product a name and 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 both the hands-free and far-field options. You’ll see a series of yes or no questions, select “No” for all of them and then click “Next.”
On the security profile screen, click “Create new profile.” Use the same name for your security profile as you did for the product ID. Then type any description you would like, then click Next.
Check the agreement and click Finish.
Click on your newly created product, then security profile, and you should see a Client ID and client secret.
In the allowed return URL entry type: https://magic-mirror-avs.github.io/Alexa-Web-Helper/authresponse
Then click the add button. Scroll down and click the update box to finish adding the URL.
In the terminal, you’ll see a prompt for the client ID. Copy the client ID from the browser, paste it into the Terminal, and then hit Enter. Now the terminal will prompt for a client secret. Switch back to the browser, copy the client secret, then paste it into Terminal and hit Enter.
When prompted for the Device ID, Enter the name you created above as a product ID (Magic_Mirror_Alexa in our example).
When you’re asked to provide a return URL, type the following command and press Enter:
You’ll see an error on the browser, but don’t worry! This is expected. Scroll through the URL of the error page and find the “Code=xxxxxx” section.
Copy the letters and numbers that appear between “code=” and “&scope” and paste them into the terminal. Hit Enter when you’re done.
When asked if you want to generate the MagicMirror config, type Y, and hit Enter.
You’ll be asked which wake word to use. Alexa is the default selection so hit Enter.
Answer no for using lite mode and visualization.
The configuration helper will generate your module information. It will look something like this:
Copy those lines. We need to add them to the Magic Mirror configuration.
Add the Alexa Module to the Magic Mirror Configuration
Then change directory to the Magic Mirror config folder with the following command:
cd ~/MagicMirror/config
And open the config.js using the nano command:
nano config.js
Just after the first instance of }, (which is the end of the module) hit Enter to create a blank line before the next { entry (which is the start of a new module).
On the new blank line you created, paste in the module code from the config helper steps. The auto-generated code does have a mistake; you’ll also need to type a comma after the final bracket so that your module ends with },
Use Ctrl+x to close the file. When prompted, type “y” to confirm the save and hit Enter to keep the file name the same.
The module is completed. To restart your Magic Mirror software with the module in place, type pm2 restart mm and the Magic Mirror software will reboot. Alexa should now work on your Magic Mirror.
This is one of the more complicated modules you can set up for the Magic Mirror. But for other modules, the basic steps are the same, download the code, configure module-specific options, add the module to configuration. You can add snowflakes to your mirror, or motion detection, or even display your Google Photos.