How to build the magic mirror
After we have hardware built for our magic mirror, now make sure your electrics are connected. Safely connected. We have just a single power supply cable coming in and it is connected to the chocbox. Chocbox splits power into two sources – for both LED and the monitor. If you’ve bought a right monitor, it has a USB connection, which you can use to provide power to the Raspberry Pi. We have already connected LEDs here and the Raspberry Pi has been connected to the monitor through HDMI.
TURN IT ON!
Here it goes, beautiful Raspbian OS. Keep moving, we are close!
Now, open the terminal clone my Github repo.
And… come in to the world of magic:
Magic Mirror uses Mysql to persist data. To run Mysql we use docker and docker-compose. Install Docker first
Luckily, python is installed in Raspbian by default. So we have pip in place already. To install docker-compose we use pip:
Here we go… We have database up and running.
Leave this tab open, please, and open another one. Now let’s try to start application
And it failed… I know… It is not perfect… Yet! So, next, we need to insert configuration data for the dashboard. Open internet browser and type:
http://localhost:8000/admin/ (don’t forget slash at the end!)
Login using credentials with username: admin, password: mcadmin and open “Config” page. There you need to set up:
- tfl.key – register for it at TFL API portal
- tfl.id – TFL API portal, same as above
- openweather.key – register at open weather API
- newsapi.key – register at news API
- national_rail.station_code – find your station code at National Rail page
- nationalrail.token – Trains live data comes from National Rail. Register here to get your token
- apple.password – icloud password to display your calendar. You need to disable two factor authentication.
- apple.id – apple id to display your calendar. Same as above
Another part of configuration is in the file ‘config.ini’.
- icloud.calendar.days_to_display – number of how many days would you like to see in the calendar.
You have already registered at news API. You can get the news sources you want to see in the dashboard there. It is possible to add multiple sources separated by coma. For ex. “the-sport-bible,bbc-sport”. You can set whatever you want for world, technology and sport news. Additionally, you can set how many items you would like to see in total.
- tfl.bus.exclude=235 – it is possible to exclude some buses which are not relevant for you.
Now let’s make it accessible just from home wifi. To get the network interfaces defined, type:
Then find ‘inet’ at ‘wlan0’ section and this is your LAN IP. Now open the file ‘mcMagicMirror/settings.py’. Add LAN IP to allowed hosts:
ALLOWED_HOSTS = [
Mirror application is accessible in your wifi zone now.
Configuration is done. Now if you just run:
Open ‘http://127.0.0.1:8000’ in your browser and get your dashboard. In order to have a full screen you can use a browser plugin.
Quick user guide
You can access the admin page from a phone, laptop or any device in your WIFI zone. Just use the LAN IP we found out above. You can hit these URLs(you can guess what they do):
As we know MaMi has an amazing alarm clock. If you go to admin page we talked before, in the Dashboard section click “config”. Here you can set:
- alarm.time – it enables alarm clock. When the time comes the mirror enables youtube playlist and LED lights. It gets back to normal once the playlist is finished.
- youtube.playlistId – playlist id you want to have as your alarm clock playlist. For ex.: https://www.youtube.com/watch?v=l482T0yNkeo&list=PL5SddC9I_hiFIFwngP44c6uEz6roo7BHW, the ID is ‘PL5SddC9I_hiFIFwngP44c6uEz6roo7BHW’
If you go to admin page we talked before, in the Dashboard section click “notes”. You can keep anything you want here. I use it for my english vocabulary.
Steps to build Magic Mirror
What we did:
- Found out what are the features and motivation under the project here.
- Built hardware – the mirror and electrics here.
- Added LED lights here.
- Installed software for mirror to become magical here.
Congratulations, we have built the magic mirror – the beauty which is useful and fits into modern home design.