Read the statement by Michael Teeuw here.
syntax errors
-
Hi guys,
I’m a beginner and I’m setting up the module MMM-AssistantMk2 but I don’t know why if I add this two configuration:record: { // Full values are in
FOR EXPERTSsection.
recordProgram: “arecord”, // Defaults to “arecord” - also supports “rec” and “sox”
device: null // recording device (e.g.: “plughw:1”)play: { // Full values are in
FOR EXPERTSsection.
playProgram: “mpg321”, // recommended.the MM show me: WARNING! Could not validate config file. Please correct syntax errors. Starting with default configuration.
Where am I wrong?
I attach my config.jsThanks everyone.
[0_1546719570197_config.js](Caricamento 100%)
-
@egnos Please show us the full
config.jsfile and mark it as Code by selecting the whole content of the file and click on the</>button.You can find a markdown tutorial here: https://commonmark.org/help/
-
Change directory to tests/configs
And runNode config_check.js
-
Sorry, the config.js below:
/* 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: "MMM-AssistantMk2", position: "top_right", config: { deviceLocation: { coordinates: { // set the latitude and longitude of the device to get localized information like weather or time. (ref. mygeoposition.com) latitude: 45.200049, // -90.0 - +90.0 longitude: 7.568917, // -180.0 - +180.0 profiles: { "default" : { // profile name. profileFile: "default.json", // profile file name. lang: "it-IT" //currently available (estimation, not all tested): // de-DE, en-AU, en-CA, en-GB, en-US, en-IN // fr-CA, fr-FR, it-IT, ja-JP, es-ES, es-MX, ko-KR, pt-BR // https://developers.google.com/assistant/sdk/reference/rpc/languages record: { // Full values are in `FOR EXPERTS` section. recordProgram: "arecord", // Defaults to "arecord" - also supports "rec" and "sox" device: null // recording device (e.g.: "plughw:1") play: { // Full values are in `FOR EXPERTS` section. playProgram: "mpg321", // recommended. } } } } } } } }, { 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://bulk.openweathermap.org/sample/; unzip the gz file and find your city 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;}Thanks.
-
Heey i just check your config file and found that there are some differences compared to the config in the readme file. Something i noticed is to check if there is a }, after each { . Example
{ module: "MMM-AssistantMk2", position: "top_right", config: { deviceLocation: { coordinates: { // set the latitude and longitude of the device to get localized information like weather or time. (ref. mygeoposition.com) latitude: 45.200049, // -90.0 - +90.0 longitude: 7.568917, // -180.0 - +180.0 }, },there is twice }, at the end to close both the {
Can you check for me if this works?{ module: "MMM-AssistantMk2", position: "top_right", config: { // --- ESSENTIALS / modifying for your environment might be needed. deviceLocation: { coordinates: { // set the latitude and longitude of the device to get localized information like weather or time. (ref. mygeoposition.com) latitude: 45.200049, // -90.0 - +90.0 longitude: 7.568917, // -180.0 - +180.0 }, }, defaultProfile: "default", // If you have several profiles and want to set one of them as default profile, describe here. profiles: { "default" : { // profile name. profileFile: "default.json", // profile file name. lang: "it-IT" //currently available (estimation, not all tested): // de-DE, en-AU, en-CA, en-GB, en-US, en-IN // fr-CA, fr-FR, it-IT, ja-JP, es-ES, es-MX, ko-KR, pt-BR // https://developers.google.com/assistant/sdk/reference/rpc/languages }, }, record: { // Full values are in `FOR EXPERTS` section. recordProgram: "arecord", // Defaults to "arecord" - also supports "rec" and "sox" device: null // recording device (e.g.: "plughw:1") }, play: { // Full values are in `FOR EXPERTS` section. playProgram: "mpg321", // recommended. }, }, }, -
Sorry @ganget, but I’m not sure that the configuration you propose can work, because after opening a “{” is closed with a “},” and the “},” is used only for the closure of the entire module and not the single configurations. Correct?
Is it possible that the problem is on the comma after “mpg321”?
play: { // Full values are in `FOR EXPERTS` section. playProgram: "mpg321", // recommended.Thank you all!
-
from the MM folder run
node tests/configs/check_config.js
find and fix all errors, starting from the top of the list
-
@ganget is right, your { } are mixed up.
This passes the test on jshint.com
/* 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: "MMM-AssistantMk2", position: "top_right", config: { deviceLocation: { coordinates: { // set the latitude and longitude of the device to get localized information like weather or time. (ref. mygeoposition.com) latitude: 45.200049, // -90.0 - +90.0 longitude: 7.568917, // -180.0 - +180.0 }, }, profiles: { "default" : { // profile name. profileFile: "default.json", // profile file name. lang: "it-IT", //currently available (estimation, not all tested): // de-DE, en-AU, en-CA, en-GB, en-US, en-IN // fr-CA, fr-FR, it-IT, ja-JP, es-ES, es-MX, ko-KR, pt-BR // https://developers.google.com/assistant/sdk/reference/rpc/languages } }, record: { // Full values are in `FOR EXPERTS` section. recordProgram: "arecord", // Defaults to "arecord" - also supports "rec" and "sox" device: null // recording device (e.g.: "plughw:1") }, play: { // Full values are in `FOR EXPERTS` section. playProgram: "mpg321", // recommended. } } }, { 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://bulk.openweathermap.org/sample/; unzip the gz file and find your city 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;}Also, if you look at the readme for this module configuration you notice the { } need to be set different.
-
@sdetweil said in syntax errors:
from the MM folder run
node tests/configs/check_config.js
find and fix all errors, starting from the top of the list
Thanks, as soon possible I will try this command.
Ok thanks @ganget, but I do not understand why if I remove the comma of the “}” referring to “play” the configuration does not give problems but if I remove the comma from the “}” referring to “record” it goes into error…
record: { // Full values are in `FOR EXPERTS` section. recordProgram: "arecord", // Defaults to "arecord" - also supports "rec" and "sox" device: null // recording device (e.g.: "plughw:1") }, play: { // Full values are in `FOR EXPERTS` section. playProgram: "mpg321", // recommended. }Sorry for the banalities … but I’m a beginner.:smiling_face_with_open_mouth_cold_sweat:
-
@egnos comma is continuation… its ok to have an EXTRA , after the play group,… it is NOT ok to have a missing , between things
-
@egnos As @sdetweil already stated the comma’s are for showing the code that there is more to run after the line. It is no problem to have a extra comma at the end. But if you don’t put a comma the code doesn’t run further and gives you a syntax error. The {} are for making a object in JS, if you don’t close the object with a } you will also get a syntax error.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login