• 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.

MMM-MirrorMirrorOnTheWall installation issue

Scheduled Pinned Locked Moved Unsolved Troubleshooting
138 Posts 11 Posters 119.7k Views 10 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.
  • O Offline
    OceanK @richland007
    last edited by Sep 4, 2018, 6:32 AM

    @richland007 So need more info here about this: At the very end of that file right before the very last } bracket
    enter the following:
    ,
    ‘Unhandled’: function () {
    this.emit(‘:ask’, ‘Sorry I didnt understand that. Say help for assistance.’);
    }
    notice the “,” right after the prior to last } before 'Unhandled" … so it wont give you a syntax error.

    So if I copy the last part from the index.js it should look like this with that extra ?

    // Send publish attempt to AWS IoT
    MirrorMirror.showVideo(result.items[0].id.videoId, searchTerm, alexaEmit);
    }
    });
    } else {
    this.emit(‘:askWithCard’, this.t(“SHOW_VIDEO_ERR”), this.t(“SHOW_VIDEO_ERR”), this.t(“ERROR_CARD”), this.t(“SHOW_VIDEO_ERR”))
    }
    }
    ,
    ‘Unhandled’: function () {
    this.emit(‘:ask’, ‘Sorry I didnt understand that. Say help for assistance.’);
    }
    };

    1 Reply Last reply Reply Quote 0
    • O Offline
      OceanK
      last edited by Sep 4, 2018, 6:23 PM

      One more thing I notice. So Im going to do this from scratch again. when I did the npm install in the src folder(MirrorMirrorOnTheWallSkill)

      I did get these infor/error:

      npm WARN deprecated alexa-sdk@1.0.25: This version of the Alexa Skills Kit SDK is no longer supported. Please use the v2 release found here: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs

      do you think thats a problem ?

      1 Reply Last reply Reply Quote 0
      • O Offline
        OceanK
        last edited by OceanK Sep 4, 2018, 7:44 PM Sep 4, 2018, 7:40 PM

        I still get lamda error. could you please add your whole index.js and MirrorMirror.js file? just delete your key. So I can see how its all together.

        then I can repack the zip and upload to lamda and try it again

        1 Reply Last reply Reply Quote 0
        • R Offline
          richland007
          last edited by Sep 5, 2018, 3:48 AM

          Here it is

          'use strict';
          /**
           * A Lambda function for handling Alexa Skill MirrorMirrorOnTheWall requests.
           *
           * Examples:
           * One-shot model:
           *  User: "Alexa On The Wall, find Snow White."
           *  Alexa: "Yes my Queen, showing images of Snow White."
           */
          
          const Alexa = require('alexa-sdk');
          
          /**
           * App ID for the skill
           * 
           * replace with your app ID 
           */
          const appId = "amzn1.ask.skill.XXXXXXXXXX-48bd-9b1c-3d309a950fcf";
          
          const MirrorMirror = require('./MirrorMirror');
          MirrorMirror.setup();
          
          const Keys = require("./certs/keys.json");
          const GoogleImages = require('google-images');
          var googleImages = new GoogleImages(Keys.cse.ID, Keys.cse.API_key);
          
          const YouTube = require('youtube-node');
          var youTube = new YouTube();
          youTube.setKey(Keys.youtube.API_key);
          
          exports.handler = function(event, context, callback) {
              let alexa = Alexa.handler(event, context);
              alexa.appId = appId;
              // To enable string internationalization (i18n) features, set a resources object.
              alexa.resources = languageStrings;
              alexa.registerHandlers(handlers);
              alexa.execute();
          };
          
          var languageStrings = {
              "en-US": {
                  "translation": {
                      "WELCOME_MESSAGE": "Hello my Queen, what can I do for you? ",
                      "WELCOME_REPROMPT": "I can show you text and images, if you give me commands like 'say you are the fairest of them all' or 'find Snow White'. I can also open or close a magic mirror module, if you say commands like 'open compliments', or 'close weather forecast'. What can I do for you, my Queen?",
                      "WELCOME_CARD": "Hello",
                      "HELP_MESSAGE": "Hello my Queen, I can show you text and images, if you give me commands like 'say you are the fairest of them all' or 'find Snow White'. I can also open or close a magic mirror module, if you say commands like 'open compliments', or 'close weather forecast'. What can I do for you, my Queen?",
                      "HELP_CARD": "Help",
                      "STOP_MESSAGE": "See you next time, my Queen!",
                      "STOP_CARD": "Goodbye",
                      "SHOW_TEXT": "Yes, my Queen. %s.",
                      "SHOW_TEXT_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'display text of hello', or 'say you are the fairest of them all'. What can I do for you, my Queen?",
                      "SHOW_TEXT_CARD": "Display Text",
                      "SHOW_IMAGE": "Yes, my Queen, showing images of %s.",
                      "SHOW_IMAGE_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'find Snow White' or 'show me images of Bill Gates'. What can I do for you, my Queen?",
                      "SHOW_IMAGE_CARD": "Show Image",
                      "TURN_ON_MODULE": "Yes, my Queen, opening module %s.",
                      "TURN_ON_MODULE_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'open current weather' or 'turn on compliments'. What can I do for you, my Queen?",
                      "TURN_ON_MODULE_CARD": "Open Module",
                      "TURN_ON_ALL_MODULES": "Yes, my Queen, opening all modules.",
                      "TURN_ON_ALL_MODULES_CARD": "Open All Modules",
                      "TURN_OFF_MODULE": "Yes, my Queen, closing module %s.",
                      "TURN_OFF_MODULE_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'close current weather' or 'turn off compliments'. What can I do for you, my Queen?",
                      "TURN_OFF_MODULE_CARD": "Close Module",
                      "TURN_OFF_ALL_MODULES": "Yes, my Queen, closing all modules.",
                      "TURN_OFF_ALL_MODULES_CARD": "Close All Modules",
                      "SHOW_VIDEO": "Yes, my Queen, showing a video of %s.",
                      "SHOW_VIDEO_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'find a video of Snow White' or 'show me a video of Bill Gates'. What can I do for you, my Queen?",
                      "SHOW_VIDEO_CARD": "Play Video",
                      "ERROR_CARD": "Error"
                  }
              },
              "en-GB": {
                  "translation": {
                      "WELCOME_MESSAGE": "Hello my Queen, what can I do for you? ",
                      "WELCOME_REPROMPT": "I can show you text and images, if you give me commands like 'say you are the fairest of them all' or 'find Snow White'. I can also open or close a magic mirror module, if you say commands like 'open compliments', or 'close weather forecast'. What can I do for you, my Queen?",
                      "WELCOME_CARD": "Hello",
                      "HELP_MESSAGE": "Hello my Queen, I can show you text and images, if you give me commands like 'say you are the fairest of them all' or 'find Snow White'. I can also open or close a magic mirror module, if you say commands like 'open compliments', or 'close weather forecast'. What can I do for you, my Queen?",
                      "HELP_CARD": "Help",
                      "STOP_MESSAGE": "See you next time, my Queen!",
                      "STOP_CARD": "Goodbye",
                      "SHOW_TEXT": "Yes, my Queen. %s.",
                      "SHOW_TEXT_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'display text of hello', or 'say you are the fairest of them all'. What can I do for you, my Queen?",
                      "SHOW_TEXT_CARD": "Display Text",
                      "SHOW_IMAGE": "Yes, my Queen, showing images of %s.",
                      "SHOW_IMAGE_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'find Snow White' or 'show me images of Bill Gates'. What can I do for you, my Queen?",
                      "SHOW_IMAGE_CARD": "Show Image",
                      "TURN_ON_MODULE": "Yes, my Queen, opening module %s.",
                      "TURN_ON_MODULE_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'open current weather' or 'turn on compliments'. What can I do for you, my Queen?",
                      "TURN_ON_MODULE_CARD": "Open Module",
                      "TURN_ON_ALL_MODULES": "Yes, my Queen, opening all modules.",
                      "TURN_ON_ALL_MODULES_CARD": "Open All Modules",
                      "TURN_OFF_MODULE": "Yes, my Queen, closing module %s.",
                      "TURN_OFF_MODULE_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'close current weather' or 'turn off compliments'. What can I do for you, my Queen?",
                      "TURN_OFF_MODULE_CARD": "Close Module",
                      "TURN_OFF_ALL_MODULES": "Yes, my Queen, closing all modules.",
                      "TURN_OFF_ALL_MODULES_CARD": "Close All Modules",
                      "SHOW_VIDEO": "Yes, my Queen, showing a video of %s.",
                      "SHOW_VIDEO_ERR": "Sorry, my Queen, I didn't get that. You can give me commands like 'find a video of Snow White' or 'show me a video of Bill Gates'. What can I do for you, my Queen?",
                      "SHOW_VIDEO_CARD": "Play Video",
                      "ERROR_CARD": "Error"
                  }
              }
          };
          
          var handlers = {
              'LaunchRequest': function() {
                  this.emit('SayHello');
              },
              'MirrorMirrorHelloIntent': function() {
                  this.emit('SayHello');
              },
              'SayHello': function() {
                  this.emit(':askWithCard', this.t("WELCOME_MESSAGE"), this.t("WELCOME_REPROMPT"), this.t("WELCOME_CARD"), this.t("WELCOME_MESSAGE") + this.t("WELCOME_REPROMPT"));
              },
              'AMAZON.HelpIntent': function() {
                  this.emit(':askWithCard', this.t("HELP_MESSAGE"), this.t("HELP_MESSAGE"), this.t("HELP_CARD"), this.t("HELP_MESSAGE"));
              },
              'AMAZON.StopIntent': function() {
                  this.emit('StopCommand');
              },
              'AMAZON.CancelIntent': function() {
                  this.emit('StopCommand');
              },
              'StopCommand': function() {
                  this.emit(':tellWithCard', this.t("STOP_MESSAGE"), this.t("STOP_CARD"), this.t("STOP_MESSAGE"));
              },
              'ShowTextIntent': function() {
                  let displayText = this.event.request.intent.slots.displayText.value;
                  if (displayText) {
                      let alexa = this
          
                      // Alexa voice/card response to invoke after text is published to AWS IoT successfully
                      let alexaEmit = function() {
                          alexa.emit(':tellWithCard', alexa.t("SHOW_TEXT", displayText), alexa.t("SHOW_TEXT_CARD"), displayText)
                      }
          
                      // Send publish attempt to AWS IoT
                      MirrorMirror.displayText(displayText, alexaEmit);
                  } else {
                      this.emit(':askWithCard', this.t("SHOW_TEXT_ERR"), this.t("SHOW_TEXT_ERR"), this.t("ERROR_CARD"), this.t("SHOW_TEXT_ERR"))
                  }
              },
              'ShowImagesIntent': function() {
                  let searchTerm = this.event.request.intent.slots.searchTerm.value;
                  if (searchTerm) {
                      let alexa = this
          
                      // Search for images
                      googleImages.search(searchTerm).then(function(images) {
                          // Only https urls are allowed for the Alexa cards
                          let imageObj = {
                              smallImageUrl: images[0].thumbnail.url,
                              largeImageUrl: images[0].thumbnail.url
                          };
                          let alexaEmit = function() {
                              alexa.emit(':tellWithCard', alexa.t("SHOW_IMAGE", searchTerm), alexa.t("SHOW_IMAGE_CARD"), searchTerm, imageObj)
                          }
          
                          // Send publish attempt to AWS IoT
                          MirrorMirror.showImages(images, searchTerm, alexaEmit);
                      })
                  } else {
                      this.emit(':askWithCard', this.t("SHOW_IMAGE_ERR"), this.t("SHOW_IMAGE_ERR"), this.t("ERROR_CARD"), this.t("SHOW_IMAGE_ERR"))
                  }
              },
              'TurnOnModuleIntent': function() {
                  let moduleName = this.event.request.intent.slots.moduleName.value;
                  if (moduleName) {
                      let alexa = this
                      let alexaEmit = function() {
                          alexa.emit(':tellWithCard', alexa.t("TURN_ON_MODULE", moduleName), alexa.t("TURN_ON_MODULE_CARD"), alexa.t("TURN_ON_MODULE", moduleName))
                      }
          
                      // Send publish attempt to AWS IoT
                      MirrorMirror.changeModule(moduleName, true, alexaEmit);
                  } else {
                      this.emit(':askWithCard', this.t("TURN_ON_MODULE_ERR"), this.t("TURN_ON_MODULE_ERR"), this.t("ERROR_CARD"), this.t("TURN_ON_MODULE_ERR"))
                  }
              },
              'TurnOnAllModuleIntent': function() {
                  let alexa = this
                  let alexaEmit = function() {
                      alexa.emit(':tellWithCard', alexa.t("TURN_ON_ALL_MODULES"), alexa.t("TURN_ON_ALL_MODULES_CARD"), alexa.t("TURN_ON_ALL_MODULES"))
                  }
                  MirrorMirror.changeModule('all_modules', true, alexaEmit);
          
              },
              'TurnOffModuleIntent': function() {
                  let moduleName = this.event.request.intent.slots.moduleName.value;
                  if (moduleName) {
                      let alexa = this
                      let alexaEmit = function() {
                          alexa.emit(':tellWithCard', alexa.t("TURN_OFF_MODULE", moduleName), alexa.t("TURN_OFF_MODULE_CARD"), alexa.t("TURN_OFF_MODULE", moduleName))
                      }
          
                      // Send publish attempt to AWS IoT
                      MirrorMirror.changeModule(moduleName, false, alexaEmit);
                  } else {
                      this.emit(':askWithCard', this.t("TURN_OFF_MODULE_ERR"), this.t("TURN_OFF_MODULE_ERR"), this.t("ERROR_CARD"), this.t("TURN_OFF_MODULE_ERR"))
                  }
              },
              'TurnOffAllModuleIntent': function() {
                  let alexa = this
                  let alexaEmit = function() {
                      alexa.emit(':tellWithCard', alexa.t("TURN_OFF_ALL_MODULES"), alexa.t("TURN_OFF_ALL_MODULES_CARD"), alexa.t("TURN_OFF_ALL_MODULES"))
                  }
                  MirrorMirror.changeModule('all_modules', false, alexaEmit);
          
              },
              'ShowVideoIntent': function() {
                  let searchTerm = this.event.request.intent.slots.searchTermVideo.value;
                  if (searchTerm) {
                      let alexa = this
          
                      // search for Youtube video
                      youTube.search(searchTerm, 1, function(error, result) {
                          if (error) {
                              console.log(error);
                          } else {
                              console.log(JSON.stringify(result, null, 2));
          
                              let imageObj = {
                                  smallImageUrl: result.items[0].snippet.thumbnails.default.url,
                                  largeImageUrl: result.items[0].snippet.thumbnails.high.url
                              };
                              let alexaEmit = function() {
                                  alexa.emit(':tellWithCard', alexa.t("SHOW_VIDEO", searchTerm), alexa.t("SHOW_VIDEO_CARD"), searchTerm, imageObj)
                              }
          
                              // Send publish attempt to AWS IoT
                              MirrorMirror.showVideo(result.items[0].id.videoId, searchTerm, alexaEmit);
                          }
                      });
                  } else {
                      this.emit(':askWithCard', this.t("SHOW_VIDEO_ERR"), this.t("SHOW_VIDEO_ERR"), this.t("ERROR_CARD"), this.t("SHOW_VIDEO_ERR"))
                  }
              },
              'Unhandled': function () {
                  this.emit(':ask', 'Sorry I didnt understand that. Say help for assistance.');
              }
          };
          

          Remember to change the appId

          1 Reply Last reply Reply Quote 0
          • R Offline
            richland007
            last edited by Sep 5, 2018, 4:16 AM

            As far as the “alexa-skills-kit-sdk-for-nodejs” goes… it wont hurt to try i guess… but i remember i have gone before and “npm install” individually all those 4 most important dependencies listed on section 2 of instructions (granted that we had many other errors before that would have ruined anything good) but that made no difference than.

            As far as hard coding the paths of certs in the mirrormirro.js file in the Skill before zipping it up…i have read it too that it should be done there also but it makes absolutely no sense to me. Because when the zip file gets unzipped in Lambda servers everything gets stored in “/var/task/…” (node_modules or etc etc directories) after /task/ so basically we are telling it to look at /pi/home/MirrorMirrorskill or whatever that does not exist. That does not exist in Lambda, unless it mirrors a mini Rpi server or whatever, but i doubt it because if you look at the other previous error logs the node_modules and its under diretories are now at /var/task/ not where we all have it locally respectively. However that syntax __dirname + “/certs/MagicMirror.private.key” in our case, means the directory stored plus the file name in nodejs as far as i can tell from a quick search since i do not know nodejs other than from here. So what i am trying to say it seems to me like its the right thing to have.
            D

            1 Reply Last reply Reply Quote 0
            • O Offline
              OceanK
              last edited by OceanK Sep 5, 2018, 7:08 AM Sep 5, 2018, 5:47 AM

              I tried your index file and replaced my key but I still get errors from the lamda test. So strange!

              I have to check more when I get home.
              .

              1 Reply Last reply Reply Quote 0
              • O Offline
                OceanK
                last edited by Sep 5, 2018, 6:23 AM

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • O Offline
                  OceanK
                  last edited by Sep 5, 2018, 9:51 AM

                  hey again!

                  I googled for some info abt this part in the index.js

                  let alexa = Alexa.handler(event, context);
                  alexa.appId = appId;

                  I found a site from 2018 7th march stating this:

                  alexa.appId = APP_ID;

                  so what do you think abt that?

                  1 Reply Last reply Reply Quote 0
                  • O Offline
                    OceanK
                    last edited by Sep 5, 2018, 4:23 PM

                    OK!

                    so now I have exatly like you. My lamda functions are OK. I test my alexa skill. She answers “what can I do for you my queen”

                    I then ask to turn off all modules. And then square on, there is a pronlem with the skill response!!! GAAAAH!

                    when you ask for videon on how to make slime for example. can you check your cloudwatch?

                    is yours looking on youtube for video but then error on throwing it back to the mirror?

                    R 1 Reply Last reply Sep 8, 2018, 8:44 PM Reply Quote 0
                    • R Offline
                      richland007
                      last edited by Sep 7, 2018, 12:37 AM

                      I have to check when i get home but i have been tired, long work hours and no patience left on me anymore lol but i feel optimistic like we are getting close like our keys are not matching now or the api
                      i will check and let you know

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 5
                      • 6
                      • 13
                      • 14
                      • 4 / 14
                      4 / 14
                      • First post
                        39/138
                        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