Magic Miror config and Ha integration

Hi all,

Many people try to setup a magic miror.
I do mine so i share my config files to help some people.

My projet is divided in 2 display (2 tablets behind a miror)

Each tablet runs WallPanel to detect motion to screen on and display each container docker running instance of magic mirror.

On the first display i have :

  • my surf condition
  • weather forecast
  • Time
  • News

On the second one :

  • Traffic Jam for my city (google maps)
  • My list for shopping
  • My to do list

For that we need 2 containers docker that is the docker-compose.yml to create that.

mirror1/docker-compose.yml

version: '2'
services:
  magic_mirror:
    image: bastilimbach/docker-magicmirror
    container_name: magic_mirror01
    ports:
      - "18081:8080"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /home/gano/docker/mirror1/config:/opt/magic_mirror/config:rw
      - /home/gano/docker/mirror1/modules:/opt/magic_mirror/modules:rw

mirror2/docker-compose.yml

version: '2'
services:
  magic_mirror:
    image: bastilimbach/docker-magicmirror
    container_name: magic_mirror
    ports:
      - "18080:8080"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /home/gano/docker/mirror2/config:/opt/magic_mirror/config:rw
      - /home/gano/docker/mirror2/modules:/opt/magic_mirror/modules:rw

You need to adapt the path to your installation.

for mirror1 this is my config.js :

    address: "",
    port: 8080,
    ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.1/120", "192.168.3.8", "172.17.0.1", , "Your_Tablet_IP"],
		{
			module: 'MMM-Hue',
			position: 'top_left',
			config: {
				bridgeip:"YOUR_BRIDGE_IP",
			 	userid: "newdeveloper",
			 	colour: true,
			 	refreshTime: 60 * 100,
			 	lightsorgroups: "groups",
			 	showOnlyOn: true
			}
		},
		{
			module: 'MMM-Memo',
			position: 'top_center',
			classes: 'default everyone',        // if using MMM-ProfileSwitcher module
			config: {
            // See 'Configuration options' for more information.
            	memoTitle: "Notes",
            	memoDisplayIfEmpty: false,
            	memoDisplayHeader: true,
            	memoDisplayId: true,
            	memoRotation: '8',
            	memoWidth: '150px',
            	memoHeight: '300px',
            	memoMaxItems: 26
        	}
        },
		{
			module: 'MMM-Memo',
			position: 'top_right',
			classes: 'default everyone',        // if using MMM-ProfileSwitcher module
			config: {
            // See 'Configuration options' for more information.
            	memoTitle: "ToDo",
            	memoDisplayIfEmpty: false,
            	memoColorBackground: "SkyBlue",
            	memoDisplayHeader: true,
            	memoDisplayId: true,
            	memoRotation: '-8',
            	memoWidth: '250px',
            	memoHeight: '300px',
            	memoMaxItems: 26
        	}
        },        
        {
            module: 'MMM-GoogleMapsTraffic',
            position: "top_left",
            config: {
                key: 'YOUR_API_KEY,
                lat: 44.833005,
                lng: -0.5930878,
                height: '300px',
                width: '400px'
            }

Change your API_KEY for GoogleMaps and LAT et LONG for your location.

For mirror2 :

    address: "",
    port: 8080,
    ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.1/120", "192.168.3.8", "172.17.0.1", , "Your_Tablet2_IP"],
    language: "fr",
	timeFormat: 24,
	units: "metric",

	modules: [
		{
			module: "alert",
		},
		{
			module: "updatenotification",
			position: "top_bar"
		},
		{
			module: "clock",
			position: "top_right"
		},
		{
			module: "currentweather",
			position: "top_right",
			config: {
				location: "Bordeaux",
				locationID: "xxxxxxx",  //ID from http://www.openweathermap.org/help/city_list.txt
				appid: "fd7f5480e4b7c64b007931c34305d337"
			}
		},
		{
			module: "weatherforecast",
			position: "top_right",
			header: "Prévisions",
			config: {
				location: "Bordeaux",
				locationID: "xxxxxx",  //ID from http://www.openweathermap.org/help/city_list.txt
				appid: "fd7f5480e4b7c64b007931c34305d337"
			}
		},		
		{
			module: 'MMM-Globe',
			position: 'top_right',
			config: {
				style: 'geoColor',
				imageSize: 400,
				ownImagePath:'modules/MMM-SimpleLogo/public/surf.png',
				updateInterval: 10 * 60 * 1000
			}
		},
		{
			module: "newsfeed",
			position: "bottom_bar",
			config: {
				feeds: [
					{
						title: "Le Monde",
						url: "http://www.lemonde.fr/rss/une.xml"
					}
				],
				showSourceTitle: false,
				showPublishDate: false
			}
		},

Ok now in Home Assistant we need to add some scripts :

  envoilistemiroir:
    alias: Envoi Liste Miroir
    sequence:
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.bieres', 'on') %} shell_command.miroirbieres {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.papierwc', 'on') %} shell_command.miroirwc {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.coca', 'on') %} shell_command.miroircoca {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.lessive', 'on') %} shell_command.miroirlessive {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.poulet', 'on') %} shell_command.miroirpoulet {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.steak', 'on') %} shell_command.miroirsteak {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.poisson', 'on') %} shell_command.miroirpoisson {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.shampooing', 'on') %} shell_command.miroirshampoo {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.geldouche', 'on') %} shell_command.miroirgeldouche {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.cafe', 'on') %} shell_command.miroircafe {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.petitdej', 'on') %} shell_command.miroirpetitdej {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.cremefraiche', 'on') %} shell_command.cremefraiche {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.tomates', 'on') %} shell_command.tomates {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.pommedeterre', 'on') %} shell_command.pommedeterre {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.poivron', 'on') %} shell_command.poivron {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.oignon', 'on') %} shell_command.oignon {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.pizza', 'on') %} shell_command.pizza {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.riz', 'on') %} shell_command.riz {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.pates', 'on') %} shell_command.pates {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.jambon', 'on') %} shell_command.jambon {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.apero', 'on') %} shell_command.apero {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.sacpoubelle', 'on') %} shell_command.sacpoubelle {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.deo', 'on') %} shell_command.deo {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.dentifrice', 'on') %} shell_command.dentifrice {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.oeufs', 'on') %} shell_command.oeufs {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.lardon', 'on') %} shell_command.lardon {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.puree', 'on') %} shell_command.puree {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.lait', 'on') %} shell_command.lait {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.glace', 'on') %} shell_command.glace {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.dessert', 'on') %} shell_command.dessert {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.paindemie', 'on') %} shell_command.paindemie {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.rhum', 'on') %} shell_command.rhum {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.sopalin', 'on') %} shell_command.sopalin {% endif %}
     - alias: Envoi la liste des courses sur le miroir
       service_template: >
        {% if is_state('input_boolean.huileolive', 'on') %} shell_command.huileolive {% endif %}
  effacelistemiroir:
    alias: Efface Liste Miroir
    sequence:
     - alias: Efface la liste des courses sur le miroir
       service: shell_command.cleanmiroir
  effacetodolist:
    alias: Efface ToDo Miroir
    sequence:
     - alias: Efface la ToDo List sur le miroir
       service: shell_command.todoclear
  addtodolist:
    alias: Add ToDo Miroir
    sequence:
     - alias: Add la ToDo List sur le miroir
       service: shell_command.todoadd       
  effacetodolistid:
    alias: Efface ToDo Miroir id
    sequence:
     - alias: Efface un element de la ToDo List
       service: shell_command.todoclearid

The shopping list is based on my previous post (To do list (shopping list))

and we need some shell_command :

todoadd: /usr/bin/curl -G -v http://192.168.3.8:18081/AddMemo?memoTitle=ToDo --data-urlencode "item={{states.input_text.text1.state}}"
tododel: bash /config/tododel.sh {{text}}
todoclear: /usr/bin/curl -G -v http://192.168.3.8:18081/RemoveMemo?memoTitle=ToDo --data-urlencode "item=ALL"; rm /config/todo_list
todoclearid: /usr/bin/curl -G -v http://192.168.3.8:18081/RemoveMemo?memoTitle=ToDo --data-urlencode "item={{states.input_text.text1.state}}"

Finaly the script tododel.sh :

echo $* > /home/gano/.homeassistant/temp_todo
sed -i -e "s/,//g" /home/gano/.homeassistant/temp_todo
sed -i -e "s/\[//g" /home/gano/.homeassistant/temp_todo
sed -i -e "s/\]//g" /home/gano/.homeassistant/temp_todo
a=`cat /home/gano/.homeassistant/temp_todo`
b=`grep -n $a todo_list|cut -d ':' -f 1`
echo `cat todo_list | grep -v $a` > /home/gano/.homeassistant/todo_listnew
/usr/bin/curl -G -v http://192.168.3.8:18081/RemoveMemo?memoTitle=ToDo --data-urlencode "item=$b"

We need also in configuration.yaml :

input_text:
  text1:
    name: Text 1
    pattern: '[a-fA-F0-9]*'

in groups.yml

  todolist:
    name: ToDo List
    entities:
      - input_text.text1
      - script.effacetodolist
      - script.effacetodolistid
      - script.addtodolist

So now in Home Assistant if someone add a text and click on “Add ToDo Memo” the text will be send on my magic mirror.
if i do a “Efface ToDo Mirror” the Memo will be destroy.

If I do a “Efface ToDo Mirror id” only the note with the number entered in the textzone will be removed.

9 Likes

I like how you have “bières” as the first item on your shopping list, just need to add “Picon” right underneath now :smiley:

1 Like

You’re right !
Priority first :smile:

Can google assistant control the Magic mirror?
eg camera display