Get Google Assistant on Your Magic Mirror!
Since Google first announced the Google Assistant back in May of 2016, a lot has changed. It has gotten smarter, adopted more widely and has an open SDK by now.
And now you can get your very own virtual assistant on your Magic Mirror. Pretty sweet.
After you install the Google Assistant module, you will be able to say “Okay Google” to your mirror and ask it questions like what the weather is, how your football team is doing and even add stuff to your grocery list. I personally use Google Assistant a lot, especially to remind me of stuff, so adding it to my mirror is a great addition for when I don’t have my phone on me.
I recommend taking a backup of your Pi’s SD card, if anything goes wrong. That way you can always roll back to your functioning Magic Mirror.
Stuff you’ll need
To be able to speak to your Google Assistant and hear the respones you’re going to need a USB mic and a speaker.
Here are a couple of options that will work with a Pi 3:
Installing MMM-GoogleAssistant
MMM-GoogleAssistant uses a pubnub model as a bridge to communicate with google assistant running on your Magic Mirror.
1. Set up the GA Module on your Magic Mirror
First, navigate to your Magic Mirror directory:
cd MagicMirror
then to your Magic Mirror modules directory:
cd modules
then, put the following command into your Raspberry Pi’s console:
git clone https://github.com/gauravsacc/MMM-GoogleAssistant.git
Navigate into the MMM-GoogleAssistant folder:
cd MMM-GoogleAssistant
Install dependencies by running the following command:
npm install
2. Create an app in pubnub
First you have to sign up for a free developer account on PubNub.
Then you create an app and get the publish and subscriber keys.
Copy the keys and replace them in the following files that are in the module, using a text editor:
- node_helper.js
- MMM-GoogleAssistant.js
- pi/assistant.py
3. Setup Google Assistant on Pi
- Setup your raspberry pi and run the sample to verify if your google assistant is working https://developers.google.com/assistant/sdk/prototype/getting-started-pi-python/run-sample
- If you are able to launch google-assistant-demo using the link above and use the assistant, you should able to use the ‘pi/assistant.py’ script that communicates with the magic mirror module.
- Install Pubnub dependencies using pip install ‘pubnub>=4.0.13’
- If you get an error while installing Pubnub, try using sudo: ‘sudo pubnub>=4.0.13’
- Download the ‘pi/assistant.py’ script on your raspberry pi and launch it via terminal
- If you see a ‘No module named google’ error try running it via /home/pi/env/bin/python3 -u assistant.py
If all goes well, you should have Google Assistant up and running on your MagicMirror.
Add it to your config file with the following code:
{
module: “MMM-GoogleAssistant”,
position: “top_right”,
config: {
maxWidth: “100%”,
header: “”
}
},