<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Alternating Modules to save on real estate]]></title><description><![CDATA[<p dir="auto">There are now so many wonderful modules out there that my MM is a bit crowded  :)</p>
<p dir="auto">So the logical question arises: might it be possible to alternate two modules in one location?</p>
<p dir="auto">I’m thinking along the lines of<br />
postion: top_left<br />
{module 1 = weather<br />
module2 = tasklist<br />
switchtime = 120 seconds}<br />
and every two minutes weather and tasklist would alternate.</p>
<p dir="auto">Thanks,<br />
Karl</p>
]]></description><link>https://forum.magicmirror.builders/topic/373/alternating-modules-to-save-on-real-estate</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 06:41:08 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/373.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Jul 2016 17:30:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Alternating Modules to save on real estate on Thu, 20 May 2021 14:21:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tobias789" aria-label="Profile: tobias789">@<bdi>tobias789</bdi></a> said in [Alternating Modules <a href="https://betterestimate.com/real-estate/austin_tx/river-place-school" target="_blank" rel="noopener noreferrer nofollow ugc">it</a> to save on real estate](/post/75481):</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kirash4" aria-label="Profile: KirAsh4">@<bdi>KirAsh4</bdi></a> Is it also possible to create alternating modules from the same type? In my case, I’m trying to alternate 2 calendar modules. Thank you very much for your answer.</p>
</blockquote>
<p dir="auto">Unfortunately, no. You can only alternate between the two modules, as prescribed in the manual.</p>
]]></description><link>https://forum.magicmirror.builders/post/91525</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/91525</guid><dc:creator><![CDATA[niksadon]]></dc:creator><pubDate>Thu, 20 May 2021 14:21:42 GMT</pubDate></item><item><title><![CDATA[Reply to Alternating Modules to save on real estate on Tue, 19 May 2020 07:21:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kirash4" aria-label="Profile: KirAsh4">@<bdi>KirAsh4</bdi></a> Is it also possible to create alternating modules from the same type? In my case, I’m trying to alternate 2 calendar modules. Thank you very much for your answer.</p>
]]></description><link>https://forum.magicmirror.builders/post/75481</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/75481</guid><dc:creator><![CDATA[tobias789]]></dc:creator><pubDate>Tue, 19 May 2020 07:21:42 GMT</pubDate></item><item><title><![CDATA[Reply to Alternating Modules to save on real estate on Thu, 21 Jul 2016 21:05:06 GMT]]></title><description><![CDATA[<p dir="auto">Yep, what you did is pretty much the idea. You figured it out and used your modules in the code. It needs to be rewritten a bit to allow for configurable module names. Possibly also allow more than just 2 modules to be swapped. There are some other things I can think of but it’s not something that’s at the top of the list for me. It is sitting in my dev repository, but it’ll be a bit before I focus on it. I’m glad what I wrote is helping you out though.</p>
]]></description><link>https://forum.magicmirror.builders/post/2791</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/2791</guid><dc:creator><![CDATA[KirAsh4]]></dc:creator><pubDate>Thu, 21 Jul 2016 21:05:06 GMT</pubDate></item><item><title><![CDATA[Reply to Alternating Modules to save on real estate on Thu, 21 Jul 2016 20:54:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kirash4" aria-label="Profile: KirAsh4">@<bdi>KirAsh4</bdi></a><br />
Thanks!  I messed around a bit with it - here is what I came up with. (and yes, 99.999% is yours!)<br />
Still, here it is for anyone else who wants to play with it. But ALL credit goes to <a class="plugin-mentions-user plugin-mentions-a" href="/user/kirash4" aria-label="Profile: KirAsh4">@<bdi>KirAsh4</bdi></a></p>
<p dir="auto">This works best for me for MMM-Wunderground   and MMM-Wunderlist - which I keep at  top-right.<br />
a) my config.js extract:</p>
<pre><code>                {
                        module: 'my_swap',      // as supplied by KirAsh4
                        config: {
                                showsecs: 30,   // seconds each module is shown (default =30)
                                                // 30 is a "relaxed" speed
                                fadems: 4000,   // fade time in ms (default = 4000)
                                                //  4000 is also very relaxed - no coffee yet.
                                modA: 'MMM-WunderGround',  // both modules need to be listed NEXT
                                modB: 'MMM-Wunderlist'     // they should be of similar size, 
                                                           // and in the same location.
                                                           // These two are _prefect_ 
                                }
                },
                {
                        module: 'MMM-WunderGround',
                        position: 'top_right',
                        config: {
                                apikey: '****',
                                pws: '****',
                                lang: 'EN',
                                fctext: '1',
                                fcdaycount: "5",
                                fcdaystart: "0",
                                hourly: '1',
                                hourlyinterval: "3",
                                hourlycount: "1",
                                alerttime: 10000,
                                alerttruncatestring: "english:",
                                fade: true
                        }
                },
                {
                        module: 'MMM-Wunderlist',
                        position: 'top_right', 
                        config: {
                                accessToken: '****',
                                clientID: '****',
                                lists: [
                                        'MagicMirror'
                                        ],
                                interval: 60,
                                fadePoint: 0.9,
                                fade: true
                                }
                },
</code></pre>
<p dir="auto">Then the file   my_swap.js ( in \modules\my_swap) needs to look like this:</p>
<pre><code>Module.register("my_swap",{

  // Default module config.
  defaults: {
        modA: "MMM-NonExistA",  // if we dont know the EXACT NAME, we don't do anything!
        modB: "MMM-NonExistB",  //    ="=
        showsecs: 30,           //  as in compliments
        fadems: 4000            //    ="=
  },

  // Define required scripts.
  getScripts: function() {
    return ["moment.js"];
  },

  start: function() {
    Log.log("Starting module: " + this.name);
    this.DOMloaded = 0;
    this.isHidden = 0;

    var self = this;
    setInterval(function() {
      self.swapModules();
    }, 1000);
  },

  notificationReceived: function(notification, payload, sender) {
    if (notification === 'DOM_OBJECTS_CREATED') {
      this.DOMloaded = 1;
    }
  },

  // swapModules.
  swapModules: function() {

    var now = moment();
    var self = this;

        var mod1 = this.config.modA     // yank from config file
        var mod2 = this.config.modB
        var fadems = this.config.fadems
        var showsecs = this.config.showsecs

    if (!(now.seconds() % showsecs)) { 
      if (this.DOMloaded) {
        if (self.isHidden) {
          MM.getModules().exceptModule(this).enumerate(function(module) {
            if (module.name === mod1) {
              module.hide(fadems, function() {
                MM.getModules().exceptModule(this).enumerate(function(module) {
                  if (module.name === mod2) {
                    module.show(fadems, function() {
                    });
                  }
                });
              });
            }
          });
          self.isHidden = 0;
        } else {
          MM.getModules().exceptModule(this).enumerate(function(module) {
            if (module.name === mod2) {
              module.hide(fadems, function() {
                MM.getModules().exceptModule(this).enumerate(function(module) {
                  if (module.name === mod1) {
                    module.show(fadems, function() {
                    });
                  }
                });
              });
            }
          });
          self.isHidden = 1;
        }
      }
    }
  }
});
</code></pre>
<p dir="auto">Works great for me! Thanks again for the clean code to play with. You should submit it as an official module.</p>
]]></description><link>https://forum.magicmirror.builders/post/2790</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/2790</guid><dc:creator><![CDATA[amanzimdwini]]></dc:creator><pubDate>Thu, 21 Jul 2016 20:54:36 GMT</pubDate></item><item><title><![CDATA[Reply to Alternating Modules to save on real estate on Wed, 20 Jul 2016 20:16:32 GMT]]></title><description><![CDATA[<p dir="auto">By the way, this works best if the two modules you are trying to swap are right below each other in the <code>'config.js'</code> file. For example, if you’re trying to swap ModA and ModB, your <code>'config.js'</code> should list them together</p>
<pre><code>modules: [
		{
			module: 'ModA',
		},
		{
			module: 'ModB',
		},
],
</code></pre>
<p dir="auto">if you have a ModC in between them, it won’t ‘swap’ properly, it’ll just turn them off in alternate fashion while keeping them in their respective location. So you’ll end up with:</p>
<pre><code>startup
ModA
ModC
ModB

then
ModC
ModB

then
ModA
ModC

alternating ...
</code></pre>
<p dir="auto">Not particularly ideal …</p>
]]></description><link>https://forum.magicmirror.builders/post/2740</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/2740</guid><dc:creator><![CDATA[KirAsh4]]></dc:creator><pubDate>Wed, 20 Jul 2016 20:16:32 GMT</pubDate></item><item><title><![CDATA[Reply to Alternating Modules to save on real estate on Wed, 20 Jul 2016 16:54:52 GMT]]></title><description><![CDATA[<p dir="auto">The fading doesn’t make it less obvious. It happens because of the different sizes per module. Fade or not, you will see the other modules in the same region jump to adjust to the new sizing. Some days my calendar will have long entries, and it makes the clock above it move. So when I hide/show the calendar, the clock will jump back and forth. The regions being flexible is what allows for longer entries on the calendar to be seen, for example. Same with the news ticker as you’ve discovered. Having fixed regions can cause other problems as well.</p>
<p dir="auto">But, this should be a start for you. As I mentioned, it’s crude, and hard coded. I much rather have a function you can pass details to but I will leave that as an exercise for you. :)</p>
]]></description><link>https://forum.magicmirror.builders/post/2728</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/2728</guid><dc:creator><![CDATA[KirAsh4]]></dc:creator><pubDate>Wed, 20 Jul 2016 16:54:52 GMT</pubDate></item><item><title><![CDATA[Reply to Alternating Modules to save on real estate on Wed, 20 Jul 2016 03:55:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kirash4" aria-label="Profile: KirAsh4">@<bdi>KirAsh4</bdi></a><br />
That was fast. Thanks. I’ll give it a whirl.</p>
<p dir="auto">Yes, I understand about all the caveats - I like the fading: that will make the jumping less obvious. But that problem already exists if you place the news-ticker at bottom_center, since it will vary between 2 and three lines. And I guess I could force the alternating modules to have the same width.</p>
<p dir="auto">BTW: thanks for teaching how to program modules. I love learning this way.</p>
]]></description><link>https://forum.magicmirror.builders/post/2727</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/2727</guid><dc:creator><![CDATA[amanzimdwini]]></dc:creator><pubDate>Wed, 20 Jul 2016 03:55:29 GMT</pubDate></item><item><title><![CDATA[Reply to Alternating Modules to save on real estate on Wed, 20 Jul 2016 00:13:56 GMT]]></title><description><![CDATA[<p dir="auto">This would be a crude way of doing it, by creating another module to manipulate the ones you want swapping. It’s crude, but it gets the job done. Ideally this would be just a routine that allows you to tell it which modules to swap, as opposed to them being hard coded like they are in this code. But, this is just to show that it’s possible. One caveat is that if one module is wider than the other, you will notice things on your screen jump around a bit. That’s just the way CSS works when an element gets removed, and the nature of the flexible regions that we use.</p>
<p dir="auto">This code swaps the default <code>calendar</code> and <code>clock</code> modules every 10 seconds, with a 2 seconds fade delay. The <code>'config.js'</code> portion is simply:</p>
<pre><code>    {
      module: 'my_swap',
    },
</code></pre>
<p dir="auto">and in <code>'modules/my_swap/'</code> I have the following file called <code>'my_swap.js'</code>:</p>
<pre><code class="language-javascript">Module.register("my_swap",{

  // Default module config.
  defaults: {
  },

  // Define required scripts.
  getScripts: function() {
    return ["moment.js"];
  },

  start: function() {
    Log.log("Starting module: " + this.name);
    this.DOMloaded = 0;
    this.isHidden = 0;

    var self = this;
    setInterval(function() {
      self.swapModules();
    }, 1000);
  },

  notificationReceived: function(notification, payload, sender) {
    if (notification === 'DOM_OBJECTS_CREATED') {
      this.DOMloaded = 1;
    }
  },

  // swapModules.
  swapModules: function() {

    var now = moment();
    var self = this;

    if (!(now.seconds() % 10)) { // Update on the tens (00, 10, 20, 30, 40, and 50)
      if (this.DOMloaded) {
        if (self.isHidden) {
          MM.getModules().exceptModule(this).enumerate(function(module) {
            if (module.name === "clock") {
              module.hide(2000, function() {
                MM.getModules().exceptModule(this).enumerate(function(module) {
                  if (module.name === "calendar") {
                    module.show(2000, function() {
                    });
                  }
                });
              });
            }
          });
          self.isHidden = 0;
        } else {
          MM.getModules().exceptModule(this).enumerate(function(module) {
            if (module.name === "calendar") {
              module.hide(2000, function() {
                MM.getModules().exceptModule(this).enumerate(function(module) {
                  if (module.name === "clock") {
                    module.show(2000, function() {
                    });
                  }
                });
              });
            }
          });
          self.isHidden = 1;
        }
      }
    }
  }
});
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/2726</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/2726</guid><dc:creator><![CDATA[KirAsh4]]></dc:creator><pubDate>Wed, 20 Jul 2016 00:13:56 GMT</pubDate></item></channel></rss>