• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

One-line switch to enable / disable modules

Scheduled Pinned Locked Moved Feature Requests
14 Posts 7 Posters 7.0k 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.
  • R Offline
    rudibarani Project Sponsor
    last edited by Jun 24, 2017, 9:37 AM

    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 / false
    

    What do you think?

    A 1 Reply Last reply Jun 24, 2017, 12:38 PM Reply Quote 0
    • A Offline
      Anhalter42 @rudibarani
      last edited by Jun 24, 2017, 12:38 PM

      @rudibarani disabled does this, doesn’t it?

      disabled 	Set disabled to true to skip creating the module. This field is optional.
      
      R 1 Reply Last reply Jun 24, 2017, 8:07 PM Reply Quote 1
      • R Offline
        rudibarani Project Sponsor @Anhalter42
        last edited by Jun 24, 2017, 8:07 PM

        @Anhalter42 That’s what I was looking for! Thanks a lot :)

        1 Reply Last reply Reply Quote 0
        • S Offline
          Sebi76
          last edited by Dec 23, 2018, 11:10 AM

          disabled: “true”, it doesnt work

          S 1 Reply Last reply Dec 23, 2018, 1:02 PM Reply Quote 0
          • S Offline
            strawberry 3.141 Project Sponsor Module Developer @Sebi76
            last edited by Dec 23, 2018, 1:02 PM

            @sebi76 booleans do not have quotes. Try without

            Please create a github issue if you need help, so I can keep track

            J 1 Reply Last reply Apr 5, 2020, 1:52 PM Reply Quote 1
            • M Offline
              michael5r Module Developer
              last edited by Dec 23, 2018, 6:19 PM

              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
              },
              
              1 Reply Last reply Reply Quote 2
              • S Offline
                Sebi76
                last edited by Dec 24, 2018, 11:06 AM

                @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			
                		},
                		
                	    ]
                
                };
                
                M 1 Reply Last reply Dec 24, 2018, 3:45 PM Reply Quote 0
                • M Offline
                  michael5r Module Developer @Sebi76
                  last edited by Dec 24, 2018, 3:45 PM

                  @sebi76 No, it needs to be before that.

                  Place it at the top of the file, before this line:

                  var config = {
                  
                  1 Reply Last reply Reply Quote 1
                  • S Offline
                    Sebi76
                    last edited by Dec 24, 2018, 5:51 PM

                    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;}
                    
                    
                    M 1 Reply Last reply Dec 24, 2018, 7:42 PM Reply Quote 0
                    • M Offline
                      michael5r Module Developer @Sebi76
                      last edited by michael5r Dec 24, 2018, 7:45 PM Dec 24, 2018, 7:42 PM

                      @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.

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