Read the statement by Michael Teeuw here.
One-line switch to enable / disable modules
-
Currently, I comment out all modules that I want to keep configured but don’t want to use currently line by line.
Is there an easier way to enable / disable modules in the config.js file?
If not, I would suggest a MM2-wide working variable (analog to header) to enable / disable modules, e.g.module_active: true / falseWhat do you think?
-
@rudibarani
disableddoes this, doesn’t it?disabled Set disabled to true to skip creating the module. This field is optional. -
@Anhalter42 That’s what I was looking for! Thanks a lot :)
-
disabled: “true”, it doesnt work
-
@sebi76 booleans do not have quotes. Try without
-
I’ve done this in my config.js file:
const DISABLED = {}; if (RPI_DEV) { // I'm setting this value automatically based on the system DISABLED.weather = false; DISABLED.clock = false; DISABLED.calendar = false; DISABLED.tools = false; DISABLED.hue = true; DISABLED.newsfeed = true; DISABLED.nest_cameras = true; DISABLED.nest_status = true; DISABLED.telegram = true; DISABLED.hotword = true; } else { DISABLED.weather = false; DISABLED.clock = false; DISABLED.calendar = false; DISABLED.tools = false; DISABLED.hue = false; DISABLED.newsfeed = false; DISABLED.nest_cameras = false; DISABLED.nest_status = false; DISABLED.telegram = false; DISABLED.hotword = false; }And then for each module you can do something like this:
{ module: 'clock', position: 'top_left', config: { displaySeconds: false, displayType: 'digital', dateFormat: 'dddd, MMM D, YYYY' }, disabled: DISABLED.clock }, -
@michael5r said in One-line switch to enable / disable modules:
I’ve done this in my config.js file:
Where do you placesd this in you config. Like this?
modules: [ const DISABLED = {}; DISABLED.clock = false; } { module: "alert", classes: 'default everyone', }, { module: "updatenotification", position: "top_bar", classes: 'default everyone', }, { module: "clock", position: "top_left", classes: 'default everyone', disabled: DISABLED.clock }, ] }; -
@sebi76 No, it needs to be before that.
Place it at the top of the file, before this line:
var config = { -
It’s works not :grimacing_face:
/* 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 * */ const DISABLED = {}; DISABLED.clock = false; }, var config = { address: "0.0.0.0", // 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: [], // 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: "de", timeFormat: 24, units: "metric", modules: [ { module: "alert", classes: 'default everyone', }, { module: "updatenotification", position: "top_bar", classes: 'default everyone', }, { module: "clock", position: "top_left", classes: 'default everyone', //disabled: DISABLED.clock }, ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") {module.exports = config;} -
@sebi76 Your syntax is wrong - you have this:
const DISABLED = {}; DISABLED.clock = false; },It should just be this:
const DISABLED = {}; DISABLED.clock = false;It’s that last
},that’s breaking your code. -
This post is deleted! -
Here is my version. No need to list all modules.
const pre_disabled = { "UNLISTED": true, // default value for unlisted other modules. "alert":false, "clock": false, "MMM-Remote-Control":false, } var DISABLED = new Proxy(pre_disabled, { get (receiver, name) { return name in receiver ? receiver[name] : receiver["UNLISTED"] } }) -
@sean said in One-line switch to enable / disable modules:
Here is my version. No need to list all modules.
const pre_disabled = { "UNLISTED": true, // default value for unlisted other modules. "alert":false, "clock": false, "MMM-Remote-Control":false, } var DISABLED = new Proxy(pre_disabled, { get (receiver, name) { return name in receiver ? receiver[name] : receiver["UNLISTED"] } })Lovely :thumbs_up_light_skin_tone:
-
This post is deleted!
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