config,js beginner



  • i am new to this, dont have a problem…(yet)

    but i just install a modul and now i have some text that i need to get in config.
    but i dont understand whear i can paste it. It contains so much ()()( on all strange thing, i just have the standard config,

    sholde i use a some program, thaht will make it alot easyer.

    Regard

    {
        module: "MMM-NowPlayingOnSpotify",
        position: "top_right",
    
        config: {
            showCoverArt: false,
            clientID: "",
            clientSecret: "",
            accessToken: "",
            refreshToken: ""
        }
    }
    

  • Module Developer

    Hi @berne welcome on board!

    You are editing a Javascript file. You can basically use any decent text editor to edit this file, however some will mallform the file. Thats why I recogmend you something like Notepad++, or Visual Studio Code.

    You just have to add this somewhere in the modules array (An array is a list of things)

    For example:

    modules: [
        {
            module: "alert",
        },
        {
            module: "MMM-NowPlayingOnSpotify",
            position: "top_right",
            config: {
                showCoverArt: false,
                clientID: "",
                clientSecret: "",
                accessToken: "",
                refreshToken: ""
            }
        },
        {
            module: "updatenotification",
            position: "top_bar"
        }
    ]
    

    Note, there must be a , character after the last } if this isn’t the last module. You can easily validate your changes by using a Javascript Linter.



  • /* 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: 24,
    	units: "metric",
    
    	modules: [
    		{
    			module: "alert",
    		},
            {
        module: "MMM-NowPlayingOnSpotify",
        position: "top_right",
    
        config: {
            showCoverArt: true,
            clientID: "",
            clientSecret: "",
            accessToken: "",
            refreshToken: ""
        }
     },
     {
         
    
    		{
    			module: "updatenotification",
    			position: "top_bar"
    		},
    		{
    			module: "clock",
    			position: "top_left"
    		},
    		{
    			module: "calendar",
    			header: "US Holidays",
    			position: "top_left",
    			config: {
    				calendars: [
    					{
    						symbol: "calendar-check",
    						url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"					}
    				]
    			}
    		},
    		{
    			module: "compliments",
    			position: "lower_third"
    		},
    		{
    			module: "currentweather",
    			position: "top_right",
    			config: {
    				location: "Vara,Sweden",
    				locationID: "2665018",  //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
    				appid: "YOUR_OPENWEATHER_API_KEY"
    			}
    		},
    		{
    			module: "weatherforecast",
    			position: "top_right",
    			header: "Weather Forecast",
    			config: {
    				location: "Vara,Sweden",
    				locationID: "2665018",  //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
    				appid: "YOUR_OPENWEATHER_API_KEY"
    			}
    
    
                
    		},
    		{
    			module: "newsfeed",
    			position: "bottom_bar",
    			config: {
    				feeds: [
    					{
    						title: "Aftonbladet",
    						url: "http://www.aftonbladet.se/nyheter/rss.xml"
    					}
    				],
    				showSourceTitle: true,
    				showPublishDate: true,
    				broadcastNewsFeeds: true,
    				broadcastNewsUpdates: true
    			}
    		},
    	]
    
    };
    
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== "undefined") {module.exports = config;}
    

    i have download the visual Studio code, i have done this, donw know if its right or not. Well see what javascipt linter is telling me…cross you finger:D

    i did something wrong, i think, i have edit the code, looks good?
    regard


  • Module Developer

    @berne You have one extra } before the updatenotification module.

    Here is the corrected config:

    /* 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: 24,
    	units: "metric",
    
    	modules: [
    		{
    			module: "alert",
    		},
    		{
    			module: "MMM-NowPlayingOnSpotify",
    			position: "top_right",
    			config: {
    				showCoverArt: true,
                    		clientID: "",
    				clientSecret: "",
    				accessToken: "",
    				refreshToken: ""
    			}
    		},     
    		{
    			module: "updatenotification",
    			position: "top_bar"
    		},
    		{
    			module: "clock",
    			position: "top_left"
    		},
    		{
    			module: "calendar",
    			header: "US Holidays",
    			position: "top_left",
    			config: {
    				calendars: [
    					{
    						symbol: "calendar-check",
    						url: "webcal://www.calendarlabs.com/ical-calendar/ics/76/US_Holidays.ics"					}
    				]
    			}
    		},
    		{
    			module: "compliments",
    			position: "lower_third"
    		},
    		{
    			module: "currentweather",
    			position: "top_right",
    			config: {
    				location: "Vara,Sweden",
    				locationID: "2665018",  //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
    				appid: "YOUR_OPENWEATHER_API_KEY"
    			}
    		},
    		{
    			module: "weatherforecast",
    			position: "top_right",
    			header: "Weather Forecast",
    			config: {
    				location: "Vara,Sweden",
    				locationID: "2665018",  //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
    				appid: "YOUR_OPENWEATHER_API_KEY"
    			}
    		},
    		{
    			module: "newsfeed",
    			position: "bottom_bar",
    			config: {
    				feeds: [
    					{
    						title: "Aftonbladet",
    						url: "http://www.aftonbladet.se/nyheter/rss.xml"
    					}
    				],
    				showSourceTitle: true,
    				showPublishDate: true,
    				broadcastNewsFeeds: true,
    				broadcastNewsUpdates: true
    			}
    		}
    	]
    };
    
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== "undefined") {module.exports = config;}
    


  • /* 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: 24,
    	units: "metric",
    
    	modules: [
    		{
    			module: "alert",
    		},
    		{
    	           module: "MMM-NowPlayingOnSpotify",
    			position: "bottom_right",
    			config: {
    				showCoverArt: true,
                    		clientID: "c162a50685084953913d4fc247758a9e",
    				clientSecret: "d464b761e3c849a3846d087a96739d0c",
    				accessToken: "BQCJP0CGFThDfAv6p8my-fkZJQjPUoQN3nBYnV4Q-jtdVRtjcx3mCaDnX9QpSKD4YfXgSVAWh3vU_Mpij_9NpyrN1KK_6lv93Ffz3IkJqUiX31WQmJXzsIatawIhTbbqx0KLdP0qK-qFQx_MKuvSrUSB",
    				refreshToken: "AQCJi17nSbRBpLbfjH6M2t-6x2FIrBlqiHC4cctLslmIj1STMwj1pTH7JJ8TUvHIonlEnogyKqltqD3KxfYzOml4PUiW-fyFHcaPhLeRTVNwyz3DtCjFblIggtYwUkF6wk0QJw"
    				}
    		},
    		{
    
    		module: "updatenotification",
    			position: "top_bar"
    		},
    		{
    			module: "clock",
    			position: "top_left"
    		},
    		{
    			module: "calendar",
    			header: "Kalender",
    			position: "top_left",
    			config: {
    				calendars: [
    					{
    						symbol: "calendar-check",
    						url: "https://calendar.google.com/calendar/ical/berntsson88%40gmail.com/public/basic.ics"					}
    				]
    			}
    		},
    		{
    			module: "compliments",
    			position: "lower_third"
    		},
    		{
    			module: "currentweather",
    			position: "top_right",
    			config: {
    				location: "Vara,Sweden",
    				locationID: "2665018",  //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
    				appid: "cb3ba3fb9618b6f6de3fbbb9ee78284e"
    			}
    		},
    		{
    			module: "weatherforecast",
    			position: "top_right",
    			header: "Weather Forecast",
    			config: {
    				location: "Vara,Sweden",
    				locationID: "5128581",  //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
    				appid: "cb3ba3fb9618b6f6de3fbbb9ee78284e"
    			}
    		},
    		{
    			module: "newsfeed",
    			position: "bottom_bar",
    			config: {
    				feeds: [
    				{
    						title: "Aftonbladet",
    						url: "http://www.aftonbladet.se/nyheter/rss.xml"
                                    },
                                    {
    					        title: "Macworld",
                                                    url: "http://feeds.idg.se/idg/FPjt",
                                    },
    	
    					]
    				],
    				showSourceTitle: true,
    				showPublishDate: true,
    				broadcastNewsFeeds: true,
    				broadcastNewsUpdates: true
    			}
    		},
    	]
    
    };
    
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== "undefined") {module.exports = config;}
    
    

    i got Spotify to work, the weather is not working and not the RSS feed, i tyde to add one more to newfeed, but it sems like i mess up my config.

    i toke a code and paste in to: jslint.com thats @idoodler did fix for me, got lots of error.

    How are u guys doing?
    if i change one thing i am messing somting up, i just what something to contoll the code, before i use in config.


  • Module Developer

    @berne You do have one error remove the lonley ] but keep the ],.

    In addition, the linter you is way to sensitive, try the one I posted, or simply use Visual Studio codes Intelisense, it will automatically show you errors…

    Linter: https://jshint.com/



  • @berne

    every module looks lie this

    {
       module:"name",
       position: " pos",
       header: "????",
       config: {
       }
    },
    

    try to make sure the [ and { line up
    inside the config the same [, { and comma pattern
    one tricky thin is onside arrays (lists of things), when the things are groups like calendar and rss feed
    there needs to be a comma after the LAST entry too

    		{
    			module: "calendar",
    			header: "Kalender",
    			position: "top_left",
    			config: {
    				calendars: [
    					{
    						symbol: "calendar-check",
    						url: "https://calendar.google.com/calendar/ical/berntsson88%40gmail.com/public/basic.ics"
    					}    // < ----- missing comma
    				]
    			}
    		},
    

    using jslint is a pain… you need to check a bunch of things on the bottom of the page,
    else get lots of useless errors,… single quotes, whitespace,


  • Module Developer

    @sdetweil There is no comma needed after the last entry, a comma is only needed if an object is followed by another object, a comma after a last object is not mandatory.



  • 102 Expected ‘}’ to match ‘{’ from line 90 and instead saw ‘]’.
    108 Expected ‘]’ to match ‘[’ from line 28 and instead saw ‘}’.
    109 Expected ‘}’ to match ‘{’ from line 11 and instead saw ‘]’.
    109 Missing semicolon.
    109 Unrecoverable syntax error. (94% scanned).

    okej, igot this,
    we can take 102 dose that mean i just need to swap to }?
    109 i have no ide what that translate :S



  • @idoodler yeh, i can never tell… some modules use the extra comma , some don’t … looked thru my config and it has one everyplace… doesn’t hurt…