MagicMirror² v2.12.0 is available! For more information about this release, check out this topic.

Weather module config



  • Just to clarify, I’m talking about the ‘weather’ module, NOT the ‘current weather’ or 'weather forecast" modules. I have added it to my config.js file with some configurations, as outlined in the documentation for the ‘weather’ module, but it wont run. Question for module configs, do I use "true", or 'true', to encapsulate my values? Its seems to vary depending on what I’m reading. Here is my config.js script:

    /* Magic Mirror Config Sample
     *
     * By Michael Teeuw http://michaelteeuw.nl
     * MIT Licensed.
     *
     * For more information on how you can configure 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 or empty, 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"],
    
    	useHttps: false, 		// Support HTTPS or not, default "false" will use HTTP
    	httpsPrivateKey: "", 	// HTTPS private key path, only require when useHttps is true
    	httpsCertificate: "", 	// HTTPS Certificate path, only require when useHttps is true
    
    	language: "en",
    	timeFormat: 24,
    	units: "metric",
    	// serverOnly:  true/false/"local" ,
    			     // local for armv6l processors, default
    			     //   starts serveronly and then starts chrome browser
    			     // false, default for all  NON-armv6l devices
    			     // true, force serveronly mode, because you want to.. no UI on this device
    
    	modules: [
    		{
    			module: "currentweather",
    			position: "top_right",
    			config: {
    				location: "Santa Barbara",
    				locationID: "5392952", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
    				appid: "112847e0ff924d7f26338d5873e7be3d"
    			}
    		},
    		{
    			module: "weatherforecast",
    			position: "top_right",
    			header: "Weather Forecast",
    			config: {
    				location: "Santa Barbara",
    				locationID: "5392952", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
    				appid: "xxxxxxxxxxxxxx"
    			}
    		},
    		{
    		module: "weather",
    		position: "top_left",
    		config: {
    			weatherProvider: "weathergov",
    			units: "metric",
    			roundTemp: "true",
    			degreeLabel: "true",
    			updateInterval" "3600000",
    			colored: "true",
    			showPrecipitationAmount: "true",
    			apiBase: "https://api.weather.gov/points/",
    			weatherEndpoint: "/forecast",
    			lat: "xxx.xxxxxx",
    			lon: "xxx.xxxxxx",
    			type: "forecast"
    		}
    	},
    	]
    
    };
    
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== "undefined") {module.exports = config;}
    

    and here are the errors I’m getting:

    [2020-04-28 11:31:59.700] [ERROR]  WARNING! Could not validate config file. Starting with default configuration. Please correct syntax errors at or above this line: /home/pi/MagicMirror/config/config.js:65
    			updateInterval" "3600000",
    			              ^^^
    
    SyntaxError: Unexpected string
        at Module._compile (internal/modules/cjs/loader.js:722:23)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:798:10)
        at Module.load (internal/modules/cjs/loader.js:645:32)
        at Function.Module._load (internal/modules/cjs/loader.js:560:12)
        at Module.require (internal/modules/cjs/loader.js:685:19)
        at require (internal/modules/cjs/helpers.js:16:16)
        at loadConfig (/home/pi/MagicMirror/js/app.js:69:12)
        at App.start (/home/pi/MagicMirror/js/app.js:210:3)
        at Object. (/home/pi/MagicMirror/js/electron.js:115:7)
        at Module._compile (internal/modules/cjs/loader.js:786:30)
    


  • @mrlowndes for numbers or true/false, no quotes, all else with quotes, doesn’t matter which kind as long as both ends are the same
    in a list it can be either for each entry, as long as both ends are the same

    updateInterval" “3600000”,

    should be name: value
    so
    updateInterval : “3600000”,



  • @sdetweil thanks. That got rid of the errors, now when I npm start the weather module seems to be just loading indefinitely. Any ideas?



  • @mrlowndes did u get an apiid? ‘loading’ means waiting for data … so, the component getting the data did not succeed

    npm start
    then look at the messages

    or possibly open the developers window (f12 or ctrl-shift-i) select the console tab, and scroll up looking for errors…



  • @mrlowndes said in Weather module config:

    index):1 Refused to apply style from ‘http://localhost:8080/css/custom.css’ because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled.

    ok, don’t know for the slow network.

    but for this one

    do

    touch ~/MagicMirror/css/custom.css
    


  • @sdetweil Thanks for the tip. The errors were at the bottom. This is what I found:

    Failed to load resource: the server responded with a status of 400 ()
    weathergov.js:55 Could not load data ...  
    XMLHttpRequest
    weather.js:151 New weather information available.
    main.js:301 [Intervention] Slow network is detected. See https://www.chromestatus.com/feature/5636954674692096 for more details. Fallback font will be used while loading: http://localhost:8080/vendor/node_modules/weathericons/font/weathericons-regular-webfont.woff
    api.openweathermap.o…xxxxxxxxxxxxxxxx:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)
    weatherforecast.js:266 weatherforecast: Your AppID does not support long term forecasts. Switching to fallback endpoint.
    (index):1 Refused to apply style from 'http://localhost:8080/css/custom.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled
    


  • @sdetweil do you know where I could get an appid for weathergov? The documentation for the module is very thin



  • no key required for that point… only works for US locations



  • @sdetweil Do you have any suggestions as to what I should try next?



  • @mrlowndes u can test that the api works from your location

    put this in your browser

    https://api.weather.gov/points/LAT,LON/forecast
    

    replace the LAT,LON
    by the values from the google maps (maps.google.com) of your location…
    in the url, you will see two numbers xx.yyyyyy,-uu.zzzzzz
    just cut/paste that whole set of numbers and paste over the LAT,LON (notice the comma comes with the numbers too)


Log in to reply