• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

[Guide] Control MM via Google Home

Scheduled Pinned Locked Moved General Discussion
24 Posts 6 Posters 7.5k Views 6 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    A Former User
    last edited by A Former User Aug 6, 2019, 3:34 PM Aug 6, 2019, 1:56 PM

    Voice command-able with Google Home + IFTTT + dataplicity.io + nginx for MagicMirror

    Notice;

    • This topic is not about how to embed Google Assistant on MagicMirror (e.g:MMM-AssistantMk2)
    • The target of this guide is for whom wants to control his MM via his existing Google Home

    Basic Concept;

    If your MM has public and static URL being accessible from outside of home network (We’ll make it with dataplicity.io & nginx), you can make IFTTT can hook the command for Google Home to send own custom message for your MagicMirror.
    It’s easier than making difficult Action for Assistant for your MM. The only downside of this method is, not so easy to make dynamic responses. (I’ll describe about it later)

    Requirements;

    • MagicMirror (connected to internet)
    • IFTTT account
    • dataplicity.io account (Free version is enough)
    • Google Home(mini) or any other Google Assistant implements. (You can also use MMM-AssistantMk2)

    Why do I use dataplicity.io instead of DDNS or ngrok?

    • Easier to maintain.
    • You don’t need to re-modify the setting when the location of MM is changed.

    Step by Step

    1. Give the public and static URL to your MM with dataplicity.io

    Alternately, you can use DDNS or ngrok or Real static IP/Domain. If you can handle them by yourself, skip step 1 & 2.

    1. Go to dataplicity.io and enter your email address. Then you can get some shell command text for your Raspberry.
      0_1565098247998_1.png

    It will similar with this. (abcd1234.py will be different per user)

    curl https://www.dataplicity.com/abcd1234.py | sudo python
    

    0_1565098299455_2.png

    Then, execute that command on your Raspberry shell terminal. dataplicity will be installed.

    1. Enable wormhole on dataplicity site.
      After installing, you need to email verification and signing. Then, you can see your device on your account page.
      The detailed layout could be different with mine. (I’m using pro account and using new interface beta.)
      0_1565098413521_3.png

    Anyway, you can find Wormhole enabling switch. Enable it and you can see the wormhole URL below the button. Remember the URL.
    0_1565098451465_4.png

    2. Install nginx

    Basically wormhole URL of free account is using port 80 but our MagicMirror usually uses higher port like 8080 or 8000. Unfortunately free dataplicity account coudn’t handle those higher ports.
    So you need to install nginx to transfer port 80 to 8080.

    Follow these instructions,

    sudo apt-get install nginx
    sudo rm /etc/nginx/sites-enabled/default
    sudo nano /etc/nginx/sites-available/mm
    

    Then, copy these and paste, and modify server_name, then save it.

    server {
        listen 80;
        server_name eouia-rpi4-device.dataplicity.io;
    
        location / {
            proxy_set_header   X-Forwarded-For $remote_addr;
            proxy_set_header   Host $http_host;
            proxy_pass         "http://127.0.0.1:8080";
        }
    }
    

    Change eouia-rpi4-device.dataplicity.io to your wormhole URL. (don’t prepend https://)
    If your MagicMirror is using other port instead of 8080, modify it also.

    After save, follow remains;

    sudo ln -s /etc/nginx/sites-available/mm /etc/nginx/sites-enabled/mm
    sudo service nginx restart
    

    To verify all settings being right, Test these;

    cd ~/MagicMirror
    node serveronly
    

    Then, open any browser (you can test it in other computer also), navigate to your wormhole URL. If MagicMirror screen is displayed, it works!

    3. Install MMM-NotificationTrigger

    You can use MMM-Remote-Control module to receive IFTTT messages. (There could be more modules which can do this stuff). But in this topic, MMM-NotificationTrigger will be used.

    Installation is easy.

    cd ~/MagicMirror/modules
    git clone https://github.com/eouia/MMM-NotificationTrigger
    

    Then open config/config.js and add configuration.

    {
      module: "MMM-NotificationTrigger",
      config: {
        useWebhook:true,
        triggers:[
          {
            trigger: "IFTTT_TEST",
            fires: [
              {
                fire:"SHOW_ALERT",
                payload: (payload) => {return payload}
              },
            ],
          },
        ]
      }
    },
    

    4. Make an IFTTT service.

    Go to IFTTT site and sign in.
    0_1565098648571_5.png
    Then make a new service.

    1. Set THIS
      0_1565098670959_6.png

    2. Search and select Google Assistant
      0_1565098715387_7.png

    3. Select simple phrase (You can make more complex phrase but this is just tutorial)
      0_1565098751427_8.png

    4. Fill the fields
      0_1565098823206_9.png

    5. Now the turn of THAT
      0_1565098855484_10.png

    6. Search and select webhooks
      0_1565098900727_11.png

    7. Go on
      0_1565098930154_12.png

    8. Fill the fields
      0_1565099564563_15.png

    For Action fields; put these values;

    • URL : "https://" + Your wormhole URL + "/webhook"
    • Method : POST
    • Content Type : application/json
    • Body :
    {
      "sender": {
        "name":"IFTTT"
      },
      "notification": "IFTTT_TEST",
      "payload":{
        "title": "From IFTTT",
        "message": "Test IFTTT on {{CreatedAt}}",
        "timer":5000
      }
    }
    

    Then finish it.
    0_1565098978667_14.png

    Now you can activate Google home by commanding “Ok Google, this is test”

    0_1565099757384_16.png
    Bingo!

    Real Usage

    • You can add wildcard for number or text to IFTTT command (e.g: “Hide module $ of mirror” or “Set volume to $”)
    • MMM-NotificationTrigger can handle notification, shell command or script and methods of specific module directly. Read the docs of MMM-NotificationTrigger
      https://github.com/eouia/MMM-NotificationTrigger
    • To make rich response; You should use TTS solution (MMM-TTS or MMM-GoogleTTS) and modify modules to speak rich response by itself instead of Google Home
    1 Reply Last reply Reply Quote 2
    • S Offline
      smackenzie5
      last edited by Aug 25, 2019, 9:01 PM

      @Sean
      I’m having trouble with Step 2 - Installing nginx.

      I was able to follow Step 1 and have a wormhole URL from Dataplicity. However, I get the following error messages when running the line “sudo apt-get install nginx”

      pi@raspberrypi:~ $ sudo apt-get install nginx
      Reading package lists... Done
      Building dependency tree       
      Reading state information... Done
      The following packages were automatically installed and are no longer required:
        libc-ares2 libhttp-parser2.8 libuv1 nodejs-doc realpath
      Use 'sudo apt autoremove' to remove them.
      The following additional packages will be installed:
        libnginx-mod-http-auth-pam libnginx-mod-http-dav-ext libnginx-mod-http-echo
        libnginx-mod-http-geoip libnginx-mod-http-image-filter
        libnginx-mod-http-subs-filter libnginx-mod-http-upstream-fair
        libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream
        nginx-common nginx-full
      Suggested packages:
        fcgiwrap nginx-doc ssl-cert
      The following NEW packages will be installed:
        libnginx-mod-http-auth-pam libnginx-mod-http-dav-ext libnginx-mod-http-echo
        libnginx-mod-http-geoip libnginx-mod-http-image-filter
        libnginx-mod-http-subs-filter libnginx-mod-http-upstream-fair
        libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream nginx
        nginx-common nginx-full
      0 upgraded, 13 newly installed, 0 to remove and 39 not upgraded.
      Need to get 1,505 kB of archives.
      After this operation, 2,563 kB of additional disk space will be used.
      Do you want to continue? [Y/n] Y
      Err:1 http://raspbian.raspberrypi.org/raspbian stretch/main armhf nginx-common all 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:2 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-http-auth-pam armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:3 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-http-dav-ext armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:4 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-http-echo armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:5 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-http-geoip armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:6 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-http-image-filter armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:7 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-http-subs-filter armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:8 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-http-upstream-fair armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:9 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-http-xslt-filter armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:10 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-mail armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:11 http://raspbian.raspberrypi.org/raspbian stretch/main armhf libnginx-mod-stream armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:12 http://raspbian.raspberrypi.org/raspbian stretch/main armhf nginx-full armhf 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      Err:13 http://raspbian.raspberrypi.org/raspbian stretch/main armhf nginx all 1.10.3-1+deb9u2
        404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/nginx-common_1.10.3-1+deb9u2_all.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-http-auth-pam_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-http-dav-ext_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-http-echo_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-http-geoip_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-http-image-filter_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-http-subs-filter_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-http-upstream-fair_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-http-xslt-filter_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-mail_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/libnginx-mod-stream_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/nginx-full_1.10.3-1+deb9u2_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/n/nginx/nginx_1.10.3-1+deb9u2_all.deb  404  Not Found [IP: 93.93.128.193 80]
      E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
      
      

      I tried continuing with the other lines but just got error messages that the files were missing.

      Thoughts?

      Thanks,
      Scott

      ? 1 Reply Last reply Aug 26, 2019, 6:59 AM Reply Quote 0
      • ? Offline
        A Former User @smackenzie5
        last edited by A Former User Aug 26, 2019, 7:00 AM Aug 26, 2019, 6:59 AM

        @smackenzie5 said in [Guide] Control MM via Google Home:

        Err:1 http://raspbian.raspberrypi.org/raspbian stretch/main armhf nginx-common

        Hmmm. Sometimes, Repositories could not be reached by accident. (Due to Network problem, DNS mismatch, Server maintenance, or any other reasons. Who knows.) Try again later.

        Before that; try this;

        sudo apt-get update
        suod apt-get upgrade
        
        S 1 Reply Last reply Aug 31, 2019, 9:17 PM Reply Quote 0
        • S Offline
          smackenzie5 @Guest
          last edited by Aug 31, 2019, 9:17 PM

          @Sean
          Can you read through the code below and determine where the error is?

          First, updating like you said did the trick. After updating/upgrading I was able to download everything and complete Step 2. Went on to complete Steps 3 & 4 and the IFTTT test worked.

          Now, I’m trying to use the format of your test code and rewrite it to turn my monitor off using OnScreenMenu. I get the following error message:

          pi@raspberrypi:~ $ cd MagicMirror
          pi@raspberrypi:~/MagicMirror $ sudo npm start
          
          > magicmirror@2.7.1 start /home/pi/MagicMirror
          > sh run-start.sh
          
          Starting MagicMirror: v2.7.1
          Loading config ...
          Loading module helpers ...
          No helper found for module: alert.
          No helper found for module: clock.
          Initializing new module helper ...
          Module helper loaded: calendar
          No helper found for module: currentweather.
          No helper found for module: weatherforecast.
          No helper found for module: MMM-google-route.
          Initializing new module helper ...
          Module helper loaded: MMM-OnScreenMenu
          Initializing new module helper ...
          Module helper loaded: MMM-NotificationTrigger
          All module helpers loaded.
          Starting server on port 8080 ... 
          Server started ...
          Connecting socket for: calendar
          Starting node helper for: calendar
          Connecting socket for: MMM-OnScreenMenu
          Connecting socket for: MMM-NotificationTrigger
          Sockets connected & modules started ...
          Launching application.
          Create new calendar fetcher for url: https://calendar.google.com/calendar/ical/xxx/basic.ics - Interval: 300000
          SyntaxError: Unexpected token a in JSON at position 96
              at JSON.parse (<anonymous>)
              at parse (/home/pi/MagicMirror/node_modules/body-parser/lib/types/json.js:89:19)
              at /home/pi/MagicMirror/node_modules/body-parser/lib/read.js:121:18
              at invokeCallback (/home/pi/MagicMirror/node_modules/body-parser/node_modules/raw-body/index.js:224:16)
              at done (/home/pi/MagicMirror/node_modules/body-parser/node_modules/raw-body/index.js:213:7)
              at IncomingMessage.onEnd (/home/pi/MagicMirror/node_modules/body-parser/node_modules/raw-body/index.js:273:7)
              at IncomingMessage.emit (events.js:182:13)
              at endReadableNT (_stream_readable.js:1090:12)
              at process._tickCallback (internal/process/next_tick.js:63:19)
          
          

          My config.js is here:

          {
              			module: 'MMM-OnScreenMenu',
              			position: 'bottom_right',
          		},
          		{
            			module: "MMM-NotificationTrigger",
            			config: {
          			    useWebhook:true,
          			    triggers:[
          			      {
           		       		trigger: "ONSCREENMENU_PROCESS_ACTION",
           		       		fires: [
           		       		  {
           		           		fire:"notificationReceived",
           		           		payload: (payload) => {return payload}
          		        	  },
          		        	       ],
          			      },
          			]
          			}
          		},
          

          My IFTTT is here:

          {
           "sender":{
            "name":"IFTTT"
           },
           "notification":"ONSCREENMENU_PROCESS_ACTION",
           "payload":{actionName: 'monitorOff'
           }
          }
          

          Thoughts?

          Thanks,
          Scott

          ? 1 Reply Last reply Sep 1, 2019, 11:24 AM Reply Quote 0
          • ? Offline
            A Former User @smackenzie5
            last edited by Sep 1, 2019, 11:24 AM

            @smackenzie5 said in [Guide] Control MM via Google Home:

            {
            “sender”:{
            “name”:“IFTTT”
            },
            “notification”:“ONSCREENMENU_PROCESS_ACTION”,
            “payload”:{actionName: ‘monitorOff’
            }
            }

            JSON syntax is somehow strict than usual JS convention.

            {
              "sender":{
                "name":"IFTTT"
              },
              "notification":"ONSCREENMENU_PROCESS_ACTION",
              "payload":{
                  "actionName": "monitorOff"
              }
            }
            

            will work. you have failed/missed on using double-quotation marks.

            1 Reply Last reply Reply Quote 0
            • S Offline
              smackenzie5
              last edited by Sep 1, 2019, 3:14 PM

              @Sean
              Thanks - that fixed the error message however it still doesn’t turn the monitor off.
              I’m not sure what else to look at now. Below is what I’m seeing but with no error message, kind of hard to tell what to work on.

              I’m considering installing Remote-Control and seeing if I can get that to work unless you’ve got another thought.

              Thanks,
              Scott

              pi@raspberrypi:~ $ cd MagicMirror
              pi@raspberrypi:~/MagicMirror $ sudo npm start
              
              > magicmirror@2.7.1 start /home/pi/MagicMirror
              > sh run-start.sh
              
              Starting MagicMirror: v2.7.1
              Loading config ...
              Loading module helpers ...
              No helper found for module: alert.
              No helper found for module: clock.
              Initializing new module helper ...
              Module helper loaded: calendar
              No helper found for module: currentweather.
              No helper found for module: weatherforecast.
              No helper found for module: MMM-google-route.
              Initializing new module helper ...
              Module helper loaded: MMM-OnScreenMenu
              Initializing new module helper ...
              Module helper loaded: MMM-NotificationTrigger
              All module helpers loaded.
              Starting server on port 8080 ... 
              Server started ...
              Connecting socket for: calendar
              Starting node helper for: calendar
              Connecting socket for: MMM-OnScreenMenu
              Connecting socket for: MMM-NotificationTrigger
              Sockets connected & modules started ...
              Launching application.
              Create new calendar fetcher for url: https://calendar.google.com/calendar/ical/xxx/basic.ics - Interval: 300000
              reqpost? { sender: { name: 'IFTTT' },
                notification: 'ONSCREENMENU_PROCESS_ACTION',
                payload: { actionName: 'monitorOff' } }
              
              
              ? 1 Reply Last reply Sep 1, 2019, 3:55 PM Reply Quote 0
              • ? Offline
                A Former User @smackenzie5
                last edited by Sep 1, 2019, 3:55 PM

                @smackenzie5
                I don’t know anything about OnScreenMenu. Have you any link to inspect?
                I think your “fire” would be wrong. “NotificationReceived” is not usual type of notification conventions. Anyway if i see how Onscreenmenu works I may tell you more.

                S 1 Reply Last reply Sep 1, 2019, 7:37 PM Reply Quote 0
                • S Offline
                  smackenzie5 @Guest
                  last edited by Sep 1, 2019, 7:37 PM

                  @Sean
                  OnScreenMenu is one of the 3rd Party modules here:
                  https://github.com/shbatm/MMM-OnScreenMenu

                  I used notificationReceived because it was similar to your example of SHOW_ALERT.
                  From alert.js - show_alert: function(params, sender) {
                  From MMM-NotificationTrigger.js - notificationReceived: function (notification, payload, sender) {
                  Maybe not correct but that’s why I did it.

                  Here’s where I got the example used for the content of notification and payload:
                  https://github.com/shbatm/MMM-AlexaOnOff/blob/master/README.md
                  Again, maybe not correct but that’s why I did it.

                  {
                      module: 'MMM-OnScreenMenu',
                      position: 'bottom_right',
                  },
                  {
                      module: 'MMM-AlexaOnOff',
                      config: {
                          devices: [{ 
                                name: "Magic Mirror",
                                on: { 
                                  notification: "ONSCREENMENU_PROCESS_ACTION",
                                  payload: { actionName:'monitorOn' }
                                },
                                off: { 
                                  notification: "ONSCREENMENU_PROCESS_ACTION",
                                  payload: { actionName:'monitorOff' }
                                },
                          }]
                      }
                  }
                  

                  Thoughts?

                  Thanks,
                  Scott

                  ? 1 Reply Last reply Sep 2, 2019, 8:00 AM Reply Quote 0
                  • ? Offline
                    A Former User @smackenzie5
                    last edited by A Former User Sep 2, 2019, 8:01 AM Sep 2, 2019, 8:00 AM

                    @smackenzie5
                    As far as I read OnScreenMenu module,
                    it needs notification like this;

                    • notification : ONSCREENMENU_PROCESS_ACTION
                    • payload:
                      • “actionName” : “monitorOn”

                    So you can make your IFTTT & NotificationTrigger recipe like this;
                    IFTTT recipe

                    {
                      "notification": "MONITOR_ON_FROM_IFTTT",
                      "payload": null
                    }
                    

                    MMM-NotificationTrigger

                    module: "MMM-NotificationTrigger",
                    config: {
                      useWebhook: true,
                      triggers: [
                        {
                          trigger: "MONITOR_ON_FROM_IFTTT",
                          fires: [
                            {
                              fire: "ONSCREENMENU_PROCESS_ACTION",
                              payload: {"actionName": "monitorOn"}
                            }
                          ]
                        }
                      ]
                    }
                    

                    I didn’t test those codes on real machine so there could be some syntax error, but I believe you can understand the concept

                    S 1 Reply Last reply Sep 3, 2019, 12:07 AM Reply Quote 0
                    • S Offline
                      smackenzie5 @Guest
                      last edited by Sep 3, 2019, 12:07 AM

                      @Sean
                      You sir, are a freakin’ genius - it works perfectly.
                      Thanks again for all the effort.

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 1 / 3
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy