The office is very impressed with the Globe module. Thanks again for making this one.
Here’s how it looks on an actual mirror.
The office is very impressed with the Globe module. Thanks again for making this one.
Here’s how it looks on an actual mirror.
@seedhe - The module framework that @MichMich created is where the technique of hosting the mirror on a Pi really shines. While the Magic Mirror is more-or-less a customizable web page, the ability for the modules to call background processes adds a level of utility.
For example, I can put a static web page up on an Amazon cloud IP and just hit that from my mirror. It will display static data and maybe some things from various APIs, if I code it cleverly enough. But that’s about it.
With the OS working behind the scenes, I can display anything behind my firewall (IP cameras, weather stations, temperature sensors, PIR sensors, etc.). I can also plug in a camera and/or microphone and use the data from those devices in my modules.
It also allows you to scale up if you need to. A Raspi is pretty slick for its size and cost. But if you put something like a NUC behind it, you can use that processing power for some really cool features. Voice recognition, facial recognition, complex animations, etc.
To answer @dsegel’s question: There are two monitors and two instances of the Magic Mirror software running. Originally, I was going to run two copies on the Fitlet, which is an i3, 8GB micro PC. But I couldn’t reliably get one instance to run on an assigned monitor. Ubuntu doesn’t have the graphics drivers for this sort of thing. I could extend the desktop to encompass both monitors, but I would end up with one interface stretched over two monitors. I tried putting the electron interface on one monitor and run a browser in kiosk mode on the other, but I couldn’t programatically guarantee that they wouldn’t both end up on the same monitor. In the end, I opted to go with two devices.
The RasPi is going to run a fairly standard mirror installation. Weather, newsfeed, traffic, calendar (I’ll set one up for the office to track visits from customers). The Fitlet is going to run my MMM-GlobeJS module and tie into our software product. We offer a VPN service with locations around the world, so my plan is to plot where our VPN exit points are on the globe as it spins. Once I get it complete to where I like it, I’ll publish the module. The RasPi uses the onboard WiFi to tie into the office network, securely log into the VPN and then shares the connection to the fitlet via ethernet. It’s not quite ready yet, but we’ll be able to log into either the Pi or the Fitlet via SSH, so I can turn our front end team loose on it.
It’s coming along. Much work left to go, but it’s coming along.
@Damian Sure, I can do that. Let me re-write this a bit.
Step 1 - Create a script called sonos.sh
in the home directory (~
).
cd ~
nano sonos.sh
Enter the following in the nano editor for the contents of your sonos.sh
script:
cd ~/node-sonos-http-api
DISPLAY=:0 npm start
Save the file and exit the nano editor.
Step 2 - Make your script executable by entering chmod +x sonos.sh
Step 3 - Tell pm2 to manage your sonos script so that it is always running in the background:
pm2 start sonos.sh
pm2 save
Verify that pm2 is managing both your sonos.sh
script and the mm.sh
script by typing pm2 status all
. You should see two lines, one for each script.
Step 4 - Clear the logs and bounce your mirror and verify that everything works as planned.
pm2 flush
pm2 restart all
I created a quick module that will map Santa as he travels around the world Christmas Eve to distribute presents. This is a quick & dirty module that uses the data from Google’s Santa Tracker suite of applications.
Santa’s location updates every minute. Grab the code at MMM-SantaTracker
First, I want thank @alexyak for his motioncontrol
module. Unfortunately for me, it doesn’t work on my Mirror due to new security controls put in place by the Node.js team. Apparently it’s not a wise move to let client-side Javascript access the webcam attached to your server. Who knew?
In the end, I ended up seeking another solution. The Facial Recognition module didn’t work due to the reduction in light coming through the mirror itself. But I do get an image. I started browsing sites of people who have turned their Raspi into a security system. It turns out, someone ported the Motion framework to Raspberry Pi and called it MMAL-Motion.
After a lot of reading, I found a Wiki for MMAL Motion. Following the steps for Jessie, I did the following:
cd ~
sudo apt-get install -y libjpeg-dev libavformat56 libavformat-dev libavcodec56 libavcodec-dev libavutil54 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev
wget https://www.dropbox.com/s/6ruqgv1h65zufr6/motion-mmal-lowflyerUK-20151114.tar.gz
tar -zxvf motion-mmal-lowflyerUK-20151114.tar.gz
This will put a configuration file called motion-mmalcam-both.conf
and a folder called motion
in your home folder. At this step you can test it if you like, but for my purposes I needed to make a few changes tot the config file. So, make a copy and edit the copy.
cp motion-mmalcam-both.conf motion.conf
nano motion.conf
I played around with the configuration quite a bit until I found one I liked. But for our purposes (turning the display on when someone comes near) you only have to make a few changes.
framerate 4
- run the detection video at 4 frames per second
threshold 2500
- increase the # of pixels to trigger the screen. We want them to get close to the mirror
minimum_motion_frames 2
- Motion must be detected in 2 consecutive frames (at 4 FPS)
event_gap 60
- This is important. This is how long in seconds after no motion the screen will turn off.
output_pictures off
- Do not save images
ffmpeg_output_movies off
- Do not record video
stream_port 0
- Turn off remote viewing
webcontrol_port 0
- Turn off HTTP control of camera
on_event_start vcgencmd display_power 1
- Important! This is the command to turn on the screen
on_event_end vcgencmd display_power 0
- Important! This is the command to turn off the screen
Save your motion.conf
file and now you can test it out by entering ./motion -c motion.conf
. If you stay very still for a minute, the screen should turn off. Move close to the mirror, and everything should come back after a couple seconds.
@motdog - No worries. We’re here to help if you run into another problem.
Here’s a quick rundown of the moving parts to a typical magic mirror:
nodejs - This is what runs the Magic Mirror framework. It technically runs a dynamic webpage which is what you see on your monitor.
npm - Node Package Manager. This is a tool that ships with nodejs that handles the downloading of required packages, compiling and running of nodejs applications - including the Magic Mirror framework.
electron - This is like a web browser that runs on the Raspi desktop. It shows what nodejs is serving up, minus all the annoying bits of a web browser (menus, address bar, etc.)
node_helper.js - This is an optional Javascript file in any module. It is responsible for passing data between the front end (display information) and the back end (calls to web services, authentication, etc.)
pm2 - This is a process monitoring application. It’s responsible for running the Magic Mirror startup script and acts as sort of a cruise control. If the Magic Mirror crashes, pm2 will detect that the script has stopped and restart it. This is normally what starts your magic mirror when it boots.
X-server - This is the desktop environment for your typical Raspberry Pi. This is what electron runs in, so it must be started in order for electron to work. I’m 90% positive that it’s also necessary for the included web browser Chromium to work. This is what your command startx
is firing up.
config.js - You’ve probably encountered this guy. This is the configuration file for the Magic Mirror web application. It helps to remember that this file is basically a Javascript data file. It controls how the web application loads and positions modules. It’s important to realize that the module itself may need to be installed/compiled before included in the config file. Including an uninstalled module isn’t going to help you much.
I hope this helps.
This is a happy little module.