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

Error in config file when adding modules, looking for another set of eyes

Scheduled Pinned Locked Moved Troubleshooting
5 Posts 4 Posters 1.8k Views 4 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.
  • E Offline
    ejoy1220
    last edited by yawns Jan 16, 2018, 4:31 PM Jan 16, 2018, 3:10 PM

    Hello, first off I am a hardware guy, coding is not something I regularly use, and I’m slowly slogging through this, it is intimidating.

    I am trying to add a Camera module with voice control to my Magic Mirror (RPi3), from https://github.com/alexyak/camera

    Here is what I have for a config file so far, but I am getting the error:

    “If you get this message while your config file is already created, your config file probably contains an error.”

    Here is my config.js contents:

    /* Magic Mirror Config Sample
     *
     * By Michael Teeuw http://michaelteeuw.nl
     * MIT Licensed.
     *
     * For more information how you can configurate this file
     * See https://github.com/MichMich/MagicMirror#configuration
     *
     */
    
    var config = {
    	address: "localhost", // Address to listen on, can be:
    	                      // - "localhost", "127.0.0.1", "::1" to listen on loopback interface
    	                      // - another specific IPv4/6 to listen on a specific interface
    	                      // - "", "0.0.0.0", "::" to listen on any interface
    	                      // Default, when address config is left out, is "localhost"
    	port: 8080,
    	ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses
    	                                                       // or add a specific IPv4 of 192.168.1.5 :
    	                                                       // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
    	                                                       // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
    	                                                       // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],
    
    	language: "en",
    	timeFormat: 12,
    	units: "imperial",
    
    	modules: [
    		{
    			module: "alert",
    		},
    		{
    			module: "updatenotification",
    			position: "top_bar"
    		},
    		{
    			module: "clock",
    			position: "top_left"
    		},
    		{
    			module: "calendar",
    			header: "US Holidays",
    			position: "top_left",
    			config: {
    				calendars: [
    					{
    						symbol: "calendar-check-o ",
    						url: "webcal://www.calendarlabs.com/templates/ical/US-Holidays.ics"
    					}
    				]
    			}
    		},
    		{
    			module: "compliments",
    			position: "lower_third"
    		},
    		{
    			module: 'camera',
    			position: 'top_center',
    			config: selfieInterval: 3,  // Time interval in seconds before the photo will be taken.
    				emailConfig: {
    				service: 'GMail', // Email provider to use to send email with a photo.
    				auth: {
    					user: '', // Your email account
    					pass: ''        // Your password for email account
    			}
    		},
    		{
    			module: 'voicecontrol',
    			position: 'bottom_left',
    			config: {
    				models: [
    				{
    					keyword: "Show Camera",
    					description: "Say 'Show Camera' to display camera",
    					file: "showCamera.pmdl",
    					message: "SHOW_CAMERA"
    				},
    				{
    					keyword: "Hide Camera",
    					description: "Say 'Hide Camera' to hide camera",
    					file: "hideCamera.pmdl",
    					message: "HIDE_CAMERA"
    				},
    				{
    					keyword: "Selfie",
    					description: "Say 'Selfie' when camera is visible",
    					file: "selfie.pmdl",
    					message: "SELFIE"
    				},
    			]
    		},
    		{
    			module: "currentweather",
    			position: "top_right",
    			config: {
    				location: "Boston",
    				locationID: "4930956",  //ID from http://www.openweathermap.org/help/city_list.txt
    				appid: "My API"
    			}
    		},
    		{
    			module: "weatherforecast",
    			position: "top_right",
    			header: "Weather Forecast",
    			config: {
    				location: "Boston",
    				locationID: "4930956",  //ID from http://www.openweathermap.org/help/city_list.txt
    				appid: "My API"
    			}
    		},
    		{
    			module: "newsfeed",
    			position: "bottom_bar",
    			config: {
    				feeds: [
    					{
    						title: "New York Times",
    						url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml"
    					}
    				],
    				showSourceTitle: true,
    				showPublishDate: true
    			}
    		},
    	]
    
    };
    

    I had a difficult time editing this natively on the Pi, have copied the config.js files to a Windows machine and using NotePad++ to edit the file, the lines lining the code up help me immensely. Wish there was an easier workflow for me to use?

    R 1 Reply Last reply Jan 16, 2018, 11:18 PM Reply Quote 0
    • D Offline
      doubleT Module Developer
      last edited by doubleT Jan 16, 2018, 4:03 PM Jan 16, 2018, 3:38 PM

      Hi,

      your config is missing a closing bracket } in the config of the camera module. To be specific, it seems like the closing bracket of “auth:” is missing.

      And it also seems weird to me that after “config:” there is no object (in brackets), but that’s how the readme of the module shows the example configuration.

      {
          module: "camera",
          position: "top_center",
          config: { // added this one, maybe missing/wrong in the example?
              selfieInterval: 3,  // Time interval in seconds before the photo will be taken.
              emailConfig: {
                  service: "GMail", // Email provider to use to send email with a photo.
                  auth: {
                      user: "", // Your email account
                      pass: ""        // Your password for email account
                  } //  this one was missing
              }
          } // added this one, maybe missing/wrong in the example?
      },
      

      And also a closing bracket missing for the config: of the voicecontrol module:

      {
          module: "voicecontrol",
          position: "bottom_left",
          config: {
                  models: [
                      {
                      keyword: "Show Camera",
                      description: "Say 'Show Camera' to display camera",
                      file: "showCamera.pmdl",
                      message: "SHOW_CAMERA"
                  },
                  {
                      keyword: "Hide Camera",
                      description: "Say 'Hide Camera' to hide camera",
                      file: "hideCamera.pmdl",
                      message: "HIDE_CAMERA"
                  },
                  {
                      keyword: "Selfie",
                      description: "Say 'Selfie' when camera is visible",
                      file: "selfie.pmdl",
                      message: "SELFIE"
                  },
              ]
          } // this one was missing
      },
      

      Some thing’s to consider: Use one sort of quotes throughout the file for strings of text. The config.js uses " while some module’s authors use '. Usually not a problem, but it’s cleaner to stick with one and helps minimize problems, for example when we look at this line from your config (which is not a problem but shows where it gets complicated):

      description: "Say 'Show Camera' to display camera",
      

      Some good ideas for people running into this to check their configs:

      • remove the last added module, run again, see if the problem is gone, if so, re-add the module and check brackets and commas, if not, re-add it, it wasn’t the source of the problem, check the next one.
      • or directly go through your file and check that every opening bracket has a matching closing bracket.
        Some text editors will highlight the closing bracket if you select the opening bracket be setting the cursor to it, or the other way round (Sublime Text does).
      1 Reply Last reply Reply Quote 0
      • R Offline
        randomnoise @ejoy1220
        last edited by Jan 16, 2018, 11:18 PM

        Wish there was an easier workflow for me to use?

        I installed samba on my pi & shared my home directory.

        You can then just browse to it from a windows machine & directly open your config.js, edit (notepad++ is the best choice imo) & then use putty to send a pm2 restart command.

        Google rpi samba as there’s plenty good info out there

        For bonus ease you could then access the mirror in a Web browser on the pc using for example 192.168.1.100:8080 (sub in your mm ip). You will first need to set the ‘interface’ parameter in your config.js to 0.0.0.0 and set the access list to include pc ip or subnet. This is how I do it so I don’t have to go & stand in front of the mirror while I’m making changes to it.

        1 Reply Last reply Reply Quote 0
        • N Offline
          ninjabreadman
          last edited by ninjabreadman Jan 16, 2018, 11:26 PM Jan 16, 2018, 11:25 PM

          Anyone having config.js issues can first copy/paste the module config (or whole thing) into JSHint (removing any API secrets or passwords). It will immediately draw attention to any syntax issues.

          Problem with config or JavaScript? Copy/paste it into JSHint.
          Check out the detailed walkthroughs on install, config, modules, etc.

          1 Reply Last reply Reply Quote 2
          • E Offline
            ejoy1220
            last edited by ejoy1220 Jan 17, 2018, 2:39 PM Jan 17, 2018, 2:38 PM

            Wow, thanks for these replies everyone.

            Blows my mind how it was just basically missing just a few “small,” to me, pieces.

            Hard to pick those out, need to step my game up and hit up CodeAcademy.

            JSHint is perfect! That will help me out a TON!

            And @RandomNoise, thank you for that idea, going to make it MUCH easier to browse and modify files that way!

            You guys rock thanks, what a great community

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              1/5
              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