Smart mirror with Amazon Echo reflection.

If you have created a smart mirror, you 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 create these modules. Options range from useful ones like Alexa or presence detection (using a camera or PIR sensor) to entertaining ones like snowflakes and Spotify playback information.

We recommend mmm-awesome-alexa as it is maintained by an active developer, although there are other Alexa modules for the Magic Mirror software.

If you prefer to install Google Assistant, Google offers a complete guide to installing Assistant on Raspberry Pi, including steps, images, and download links. While there are several Magic Mirror modules for Google Assistant, our research has shown that these modules are problematic, often causing mirror information to fail or be reflected. If you want the easiest setup possible, we recommend adding the Google AIY kit and using its dedicated guide.

To install most modules, you will go through a few basic steps:

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

Depending on the module, steps two and three may be more or less involved. For example, setting up Alexa requires more settings than adding snowflakes. Also, this particular Alexa module requires additional software (dependencies) to be installed before the module can be loaded.

RELATED: How to build your own futuristic smart mirror

Materials you will need

Google AIY voice dialing
Google

This guide assumes that you have already created a Smart Mirror. If you haven’t already, start here, but keep in mind the additional materials listed here based on your cost and space.

  • Completed Smart Mirror
  • Microphone
  • Speaker

For the microphone and speaker, we recommend the original Google AIY Voice Kit. At $16, you’d be hard-pressed to find a cheaper mic/speaker combo. You don’t have to use the included carton; it may be more efficient to leave the components outside and run the microphone and speaker outside of the mirror.

A second version of the Google AIY Voice Kit is available, but it’s more expensive and includes a Raspberry Pi Zero that isn’t powerful enough to run awakened words or Magic Mirror software, so you should skip it.

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

Installing module dependencies

Before you can download and configure mmm-awesome-alexa, you need to install a few dependencies that the module relies on. It’s always a good idea to update your Raspberry Pi before installing anything else. On your Raspberry Pi, run the following command:

  обновление sudo & ap & обновление sudo apt 

Once your Raspberry Pi is updated, run the following commands one by one:

  sudo apt-get установить sox libsox-fmt-all
 sudo apt-get установить swig3.0 python-pyaudio python3-pyaudio sox
 pip install pyaudio
 sudo apt-get установить libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg libav-tools
 sudo apt-get установить libatlas-base-dev 

Each command installs a dependency and they are all required to run. Just run the command, wait for the download and installation to complete, then run the following command.

Loading the module code

The first step to adding any module to Magic Mirror is to download the Github module code. To do this, you need to log into your Raspberry Pi, open a terminal, and navigate to the directory where the modules are stored. You will then use the 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, enter the following:

  cd ~ / MagicMirror / modules

This command moves you to the working directory of the modules folder for the Magic Mirror software. Every time you upload a new module, you need to be there to keep everything organized. The next step is to download the software from Github using this command:

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

When it finishes, change the directories to the module with the following command:

  cd MMM-офигенно-алексей 

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

  npm install --only = prod 

Now change directories to the newly created node_modules folder:

  cd node_modules 

Delete the «Snowboy» folder added by the previous commands. We need a new version of Snowboy:

  рм-рф сноубой 

Next, we will download the latest version of Snowboy with the following command:

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

Before we continue, change the directory to the new Snowboy folder.

  CD Snowboy 

Now we need to remove the node_modules folder and install some additional dependencies. It’s important that you stay in the «Snowboy» folder for these steps; do not change directories. Run the following commands one by one:

  rm -rf node_modules
 npm установить nan - сохранить 
 npm install node-pre-gyp@0.12.0 - сохранить 
 установка npm 
 Npm Run Prepublish 
 npm install --save-dev электронное восстановление 
 нпм установить нан 
 ./node_modules/.bin/electron-rebuild 

The module is now fully loaded and installed.

Setting up the Alexa module

Setup assistant 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 directories in the root of the module. In the terminal, type the following command and press Enter:

  cd ~ / MagicMirror / modules / MMM-офигенно-алексей 

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

  npm запустить config-helper 

You will see a prompt asking for a client ID. Since you are essentially setting up the Echo, you need to open your browser and go to the Alexa developer site. Then sign in to your Amazon account.

After logging in, click the «Get Started» button. You are creating a device, so click «Products» and click «Create Product».

The Alexa developer dialog with a border 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 turn on the handsfree and remote field options. You will see a series of yes or no questions, select No for all of them and click next.

On the security profile screen, click «Create a new profile». Use the same name for your security profile as for your product ID. Then enter any description you want, then click Next.

Review the agreement and click Done.

Click on your new product, then Security Profile, and you should see the Client ID and Client Secret.

In the resolved return URL, enter:
https://magic-mirror-avs.github.io/Alexa-Web-Helper/authresponse

Then click the Add button. Scroll down and click the update box to complete adding the URL.

In the terminal, you will see a request for a client ID. Copy the client ID from the browser, paste it into the terminal and press Enter. The terminal will now ask for a client secret. Return to the browser, copy the client secret, then paste it into the terminal and press Enter.

When prompted to enter a Device ID, enter the name you created above as the Product ID (Magic_Mirror_Alexa in our example).

When asked to provide a return URL, type the following command and press Enter:

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

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

Alexa voice services permissions are highlighted with the

You will see an error in the browser, but don’t worry! This is expected. Scroll through the URL of the error page and look for the «Code=xxxxxx» section.

URL showing the Alexa device code.

Copy the letters and numbers that appear between «code=» and «&scope» and paste them into the terminal. Press Enter when you’re done.

When asked if you want to create a MagicMirror configuration, type Y and press Enter.

You will be asked which wake-up word to use. Alexa is selected by default, so press Enter.

Answer no for using light mode and visualization.

The configuration assistant will generate information about your module. It will look something like this:

  {
  модуль: "МММ-офигенно-алексей",
  позиция: "нижняя панель",
  config: {
  wakeWord: "Alexa",
  clientId: "YOUR_CLIENT_ID",
  clientSecret: "YOUR_CLIENT_SECRET",
  ID устройства: "YOUR_DEVICE_ID",
  refreshToken: "YOUR_REFRESH_TOKEN",
  Lite: ложь,
  isSpeechVisualizationEnabled: false
  }
  }

Automatically generated module code.

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

Add Alexa module to Magic Mirror configuration

Then navigate to the Magic Mirror configuration folder with the following command:

cd ~/MagicMirror/config

And open config.js with the nano command:

nanoconfig.js

Immediately after the first instance }, (which is the end of the module) press Enter to create an empty line before the next { entry (which is the start of a new module).

modules code, with newline inserted after } and before {

In the new blank line you created, paste the module code from the configuration assistant steps. There is a bug in the auto-generated code; you will also need to enter a comma after the last parenthesis so that your module ends with },

inserted module code with a comma added after the last parenthesis

Use Ctrl + x to close the file. When prompted, type «y» to confirm saving and press Enter to keep the filename the same.

Module completed. To restart the Magic Mirror software with the module installed, type pm2 restart mm and the Magic Mirror software will restart. Alexa should now work on your magic mirror.

This is one of the more complex modules that you can set up for Magic Mirror. But for other modules, the basic steps are the same, upload the code, configure the module parameters, add the module to the configuration. You can add snowflakes to your mirror, or motion detection, or even display your Google Photos.

Похожие записи