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.

    Config.js file Syntax

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    26 Posts 7 Posters 25.4k 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.
    • Mykle1M Offline
      Mykle1 Project Sponsor Module Developer @amosh83
      last edited by

      @amosh83

      Blink!

      Your config.js.sample file was supposed to be copied and renamed to config.js. If you really have “eliminated” that file then you can use this. Copy and paste it into a new file, by itself, and name the file config.js and save. Put it in your config folder.

      /* Magic Mirror Config file
       *
       * By Michael Teeuw http://michaelteeuw.nl
       * MIT Licensed.
       */
      
      var config = {
      	port: 8080,
      	ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses.
      
      	language: "en",
      	timeFormat: 24,
      	units: "metric",
      
      	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: "currentweather",
      			position: "top_right",
      			config: {
      				location: "New York",
      				locationID: "",  //ID from http://www.openweathermap.org/help/city_list.txt
      				appid: "YOUR_OPENWEATHER_API_KEY"
      			}
      		},
      		{
      			module: "weatherforecast",
      			position: "top_right",
      			header: "Weather Forecast",
      			config: {
      				location: "New York",
      				locationID: "5128581",  //ID from http://www.openweathermap.org/help/city_list.txt
      				appid: "YOUR_OPENWEATHER_API_KEY"
      			}
      		},
      		{
      			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
      			}
      		},
      	]
      
      };
      
      /*************** DO NOT EDIT THE LINE BELOW ***************/
      if (typeof module !== "undefined") {module.exports = config;}
      
      

      Create a working config
      How to add modules

      A 1 Reply Last reply Reply Quote 0
      • A Offline
        amosh83 @Mykle1
        last edited by

        @Mykle1 did that and when I open the Index.html it’s still showing me the same issue " create a config file - if you get this message while your config file is already created, your config file probably contains an error…"

        I have a Raspberry pi b+
        Have all node and npm installed and updated,

        • Trying to run it in server mode only with " node serveronly but when I “point my browser” to ```
          http://localhost:8080 I receive this message " Your device is not allowed to access your mirror, please check you config.js file…"

        • Tried PM2 start mm… and says that "mm’s status is online, mode is fork, and that process is successfully started but I don’t see any Magic Mirror showing up.

        • tried npm start no luck

        Mykle1M 1 Reply Last reply Reply Quote 0
        • Mykle1M Offline
          Mykle1 Project Sponsor Module Developer @amosh83
          last edited by

          @amosh83 said in Config.js file Syntax:

          @Mykle1 did that and when I open the Index.html it’s still showing me the same issue " create a config file - if you get this message while your config file is already created, your config file probably contains an error…"

          The config.js file I posted works. I just tested it. It’s a copy of the config.js.sample file that comes with the installation of MM. Make a copy of yours and rename it and try that. If what I posted still reports that error then something is going wrong in the way that you are creating the config.js file using it, or where you are putting the file.

          I have a Raspberry pi b+
          Have all node and npm installed and updated,

          Trying to run it in server mode only with " node serveronly but when I “point my browser” to ```
          http://localhost:8080 I receive this message " Your device is not allowed to access your mirror, please check you config.js file…"

          You likely need to whitelist the IP address of the computer you’re using to access the mirror. See this line in the config.js file that I posted originally.
          ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses.

          Tried PM2 start mm… and says that "mm’s status is online, mode is fork, and that process is successfully started but I don’t see any Magic Mirror showing up.

          pm2 start mm takes a few moments to run the mirror, maybe longer on a Pi b+. I’d wait 30 seconds before cancelling that command.

          tried npm start no luck

          Has to be run in the MagicMirror directory only.

          Really, you should post your terminal errors and console errors.

          Create a working config
          How to add modules

          1 Reply Last reply Reply Quote 0
          • bheplerB Offline
            bhepler Module Developer
            last edited by

            @amosh83 - Well, progress. You have a config.js file in the right place and it’s passing the syntax checks. Let’s start at basic functionality and move to a working mirror.

            First, edit your config.js to allow everyone to connect and see the interface. Change this line:
            ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses.
            to read like this:
            ipWhitelist: [],

            Next, let’s turn off pm2 management: pm2 stop mm
            And finally, let’s start the server and see if you can get an interface:

            cd /home/pi/MagicMirror
            node serveronly
            

            Watch for any lines that say “error”. Don’t worry about lines that say “warn”. Once the console stops spitting out lines of text, try to view your pi in your browser. If you’re using the browser on the pi, then http://localhost:8080 should work. If you’re using the browser on another computer, then http://(pi ip address):8080 should work. You should see a basic mirror interface in your web browser.

            Give it a go and let us know if you have any success. We’ll get the fullscreen interface up afterwards.

            A Mykle1M 2 Replies Last reply Reply Quote 0
            • A Offline
              amosh83 @bhepler
              last edited by

              @bhepler hello, Thank you for the detailed instructions so far, that’s exactly the kind of guidance I needed based on my level of knowledge… I did all the steps and everything was going smooth until my last step where I see the usual black screen

              “Magic Mirror2
              Please create a config file.
              See README for more information.
              If you get this message while your config file is already
              created, your config file probably contains an error.
              Use a JavaScript linter to validate your file”

              here’s a copy of my current config.js file with the ipwhitelist edit you suggested…

               * MIT Licensed.
               */
              
              var config = {
                      port: 8080,
                      ipWhitelist: [], // Set [] to allow all IP addresses.
              
                      language: "en",
                      timeFormat: 24,
                      units: "metric",
              
                      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: "currentweather",
                                      position: "top_right",
                                      config: {
                                              location: "New York",
                                              locationID: "",  //ID from http://www.openweathermap.org/help/city_list.txt
                                              appid: "YOUR_OPENWEATHER_API_KEY"
                                      }
                              },
                              {
                                      module: "weatherforecast",
                                      position: "top_right",
                                      header: "Weather Forecast",
                                      config: {
                                              location: "New York",
                                              locationID: "5128581",  //ID from http://www.openweathermap.org/help/city_list.txt
                                              appid: "YOUR_OPENWEATHER_API_KEY"
                                      }
                             },
                              {
                                      module: "weatherforecast",
                                      position: "top_right",
                                      header: "Weather Forecast",
                                      config: {
                                              location: "New York",
                                              locationID: "5128581",  //ID from http://www.openweathermap.org/help/city_list.txt
                                              appid: "YOUR_OPENWEATHER_API_KEY"
                                      }
                              },
                              {
                                      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
                                      }
                              },
                      ]
              
              };
              
              /*************** DO NOT EDIT THE LINE BELOW ***************/
              if (typeof module !== "undefined") {module.exports = config;}
              
              

              thank you

              Mykle1M L 2 Replies Last reply Reply Quote 0
              • Mykle1M Offline
                Mykle1 Project Sponsor Module Developer @amosh83
                last edited by

                @amosh83

                That config is fine. I just tested it. I don’t mean to intrude but is your config,js file in the correct directory? MM should have no problem with that config, unless it couldn’t find it.

                0_1499393709814_help.JPG

                Create a working config
                How to add modules

                A 1 Reply Last reply Reply Quote 0
                • Mykle1M Offline
                  Mykle1 Project Sponsor Module Developer
                  last edited by Mykle1

                  Huh, according to your config you use the same locationID that I do. Welcome to NYC! :-)

                  Create a working config
                  How to add modules

                  A 1 Reply Last reply Reply Quote 0
                  • A Offline
                    amosh83 @Mykle1
                    last edited by

                    @Mykle1 Yes, the file is there, same directory as the one shown above

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      amosh83 @Mykle1
                      last edited by

                      @Mykle1 I just didn’t modify a thing from that file, just to make it work, once I see it up and running I’ll slowly customize it. I’m in Pennsylvania :)

                      1 Reply Last reply Reply Quote 1
                      • Mykle1M Offline
                        Mykle1 Project Sponsor Module Developer @bhepler
                        last edited by

                        @bhepler said in Config.js file Syntax:

                        @amosh83 - Well, progress. You have a config.js file in the right place and it’s passing the syntax checks.

                        Maybe I should have paid more attention while reading. I see now that I asked something that you had already established. My bad.

                        I am extremely curious to see how MM can report "Please create a config file. See README for more information. If you get this message while your config file is already created, your config file probably contains an error." when there is a working config in the proper directory.

                        Create a working config
                        How to add modules

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 3 / 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