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 8.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.
    • S Offline
      Sebi76
      last edited by

      @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			
      		},
      		
      	    ]
      
      };
      
      michael5rM 1 Reply Last reply Reply Quote 0
      • michael5rM Offline
        michael5r Module Developer @Sebi76
        last edited by

        @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

          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;}
          
          
          michael5rM 1 Reply Last reply Reply Quote 0
          • michael5rM Offline
            michael5r Module Developer @Sebi76
            last edited by michael5r

            @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
            • S Offline
              Sebi76
              last edited by Sebi76

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • ? Offline
                A Former User
                last edited by A Former User

                @rudibarani @michael5r

                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"]
                  }
                })
                
                michael5rM 1 Reply Last reply Reply Quote 1
                • michael5rM Offline
                  michael5r Module Developer @Guest
                  last edited by

                  @sean said in One-line switch to enable / disable modules:

                  @rudibarani @michael5r

                  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:

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    jg3 @strawberry 3.141
                    last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • 1
                    • 2
                    • 2 / 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