MagicMirror

From The World according to Vissie
Jump to navigation Jump to search

Setup Magic Mirror on a Raspberry Pi Zero W

http://emmanuelcontreras.com/how-to/how-to-create-a-magic-mirror-2-with-pi-zero-w/

Setting up WiFi

Add the following to the file (make sure you don’t misspell your SSID and spend 20 minutes figuring out why it isn’t working :/)

vim: /etc/wpa_supplicant/wpa_supplicant.config
network={
ssid=”Your_wifi_name”
psk=“Your_wifi_password”
}
sudo apt update && sudo apt upgrade

SSH into Rpi

Figure out what IP address the rpi has and ssh into it

sudo apt install vim atool

Install Node.js

Get latest version of node

wget https://nodejs.org/dist/v8.3.0/node-v8.3.0-linux-armv6l.tar.xz
aunpack node-v8.3.0-linux-armv6l.tar.xz
cd node-v8.3.0-linux-armv6l
sudo cp -R * /usr/local/
sudo reboot

Install NPM

sudo apt install npm

Install git

sudo apt install git
cd or cd ~/

Clone magic mirror repo

git clone https://github.com/MichMich/MagicMirror

Install magic mirror

cd MagicMirror

npm install

grab a beer and wait like 20 minutes

Install a Browser

sudo apt-get install chromium-browser

grab another beer (but don’t get drunk, we aren’t done)

AutoLogin to raspberry pi

sudo raspi-config
Boot Options -> B1 Desktop/CLI -> B2 Console Autologin

Install xinit (program that allows you to start “x” server)

sudo apt-get install xinit

Install Xorg (display server)

sudo apt install xorg

Install matchbox (window manager)

sudo apt install matchbox
sudo apt install openbox

Get rid of cursor with Unclutter

sudo apt install unclutter

Make two script files

mmstart.sh – for starting MagicMirror and xserver/midori on startup

vim: /mmstart.sh
#!/bin/bash
cd ~/MagicMirror
node serveronly &
sleep 30
xinit /home/pi/start_mm.sh
vim: ~/midori_start.sh
#!/bin/sh
unclutter &
xset -dpms # disable DPMS (Energy Star) features.
xset s off # disable screen saver
xset s noblank # don’t blank the video device
openbox &
chromium-browser --kiosk http://localhost:8080

Make both files executable

sudo chmod a+x mmstart.sh
sudo chmod a+x midori_start.sh
vim: /etc/X11/Xwrapper.config
...
allowed_users=anybody
...

Auto Starting MagicMirror (I followed the guide on the MM github page)

sudo npm install -g pm2
pm2 startup

Copy and paste the command that the screen prints out

pm2 start mmstart.sh

magic mirror should start running and midori displaying it

pm2 save

NOTE: Upon reboot, it takes about 1-2 minutes for magic mirror to startup, be patient!

Your Magic Mirror should now be up and running, time to add your modules and configure it!


My modules

Weather:

git clone https://github.com/jclarke0000/MMM-MyWeather.git 
vim: ~/MagicMirror/config/config.js
        {                 
                    module: 'MMM-MyWeather', //https://github.com/jclarke0000/MMM-MyWeather
                    position: 'top_right',
                    config: {
                            apikey: 'APIPKEY1234567890', // private; don't share!
                            pws: 'pws:ICENTURI26', //centurion
                            hourly: '1', 
                            fctext: '1',
                            fcdaycount: "5",
                            fcdaystart: "0",
                            hourlyinterval: "3",
                            hourlycount: "2",
                            alerttime: 10000,
                            alerttruncatestring: "english:",
                            roundTmpDecs: 1,
                            UseCardinals: 0,
                            layout: "vertical",// horizontal, vertical
                            sysstat: 0,
                            iconset: "colourful",
                            coloricon: true,
                            fade: false
                          }
                },


vim: ~/MagicMirror/config/config.js
           {
                   module: 'MMM-Traffic',
                    position: 'top_left',
                    classes: 'dimmed medium', //optional, default is 'bright medium', only applies to commute info not route_name
                    config: {
                            api_key: 'Google1234567890API0987654321',
                                mode: 'driving',
                                origin: '6 My home adress some where',
                                destination: 'at work some point',
                                //fri_destination: '1 E 161st St, Bronx, NY 10451',
                                arrival_time: '0700', //optional, but needs to be in 24 hour time if used.
                                route_name: 'Home to Work',
                                changeColor: true,
                                showGreen: true,
                                limitYellow: 5, //Greater than 5% of journey time due to traffic
                                limitRed: 20, //Greater than 20% of journey time due to traffic
                                traffic_model: 'pessimistic',
                                showRouteInfo: true,
                                showRouteInfoText: '{routeName} via {summary}',
                                loadingText: 'Loading Home to Work commute ...',
                                showWeekend: false,
                                //showAddress: true,
                                interval: 120000 //2 minutes
                            }
            },
vim: ~/MagicMirror/config/config.js
            {                                                                                                                                                              
                   module: 'MMM-Traffic',
                    position: 'top_left',
                    classes: 'dimmed medium', //optional, default is 'bright medium', only applies to commute info not route_name
                    config: {
                            api_key: 'SomeGoogle1234567890API0987654321KEY',
                                mode: 'driving',
                                origin: 'Where do i live agian',
                                destination: 'take me home please',
                                //fri_destination: '1 E 161st St, Bronx, NY 10451',
                                //arrival_time: '0700', //optional, but needs to be in 24 hour time if used.
                                route_name: 'Work to home',
                                changeColor: true,
                                showGreen: true,
                                limitYellow: 5, //Greater than 5% of journey time due to traffic
                                limitRed: 20, //Greater than 20% of journey time due to traffic
                                traffic_model: 'pessimistic',
                                showRouteInfo: true,
                                showRouteInfoText: '{routeName} via {summary}',
                                loadingText: 'Loading Work to Home commute ...',
                                prependText: 'Driving Home should take',
                                showWeekend: false,
                                //showAddress: true,
                                interval: 120000 //2 minutes
                            }
            },