MagicMirror² v2.12.0 is available! For more information about this release, check out this topic.

Is hidden the same as disabled?


  • Project Sponsor

    Is there a way to start a module hidden (or is this the same as disabled)?

    I would like to have MMM-Snow on „standby“ to be shown at specific times.


  • Module Developer


  • Project Sponsor

    Thanks @Sean for the idea.

    I plan to use MMM-Snow during some days in the winter. The problem with MMM-Module Scheduler is, that it only seems to hide/show models when passing the point in time that triggers an event. Therefore, I would like to have MMM-Snow reliably hidden when restarting the mirror.

    I did find that MMM-Remote-Control allows to manually hide / show modules and save the “state”. But this information is lost every time the config is changed and does not seem to work fully reliably.

    I tried to show modules that are marked “disabled” in the config via show / hide notifications, but that does not seem to work…


  • Module Developer

    What could be the trigger to reveal that module from hiding? by manual?

    I think to add this modifying in MMM-Snow.js could be help, but not tested.

    start: function() {
      this.hide()
    },
    

    Or,

    notificationReceived: function(noti, payload, sender) {
      if (noti == "DOM_OBJECTS_CREATED") {
        this.hide()
      }
    },
    

  • Project Sponsor

    @sean I will try your code - thanks for the advice. I wanted to use the notification system to show and re-hide a module when the time is due.


  • Module Developer

    @rudibarani said in Is hidden the same as disabled?:

    the notification system to show and re-hide a module when the time is due.

    This is somehow obvious. Is it by a schedule? In that case MMM-Scheduler can control its showing and hiding. Even start with hiding.
    https://github.com/ianperrin/MMM-ModuleScheduler#individual-module-schedules
    Or any other trigger? But MMM-Snow itself has no feature of self hiding/revealing by notification. Other module should hide/show MMM-Snow.


  • Project Sponsor Module Developer

    @rudibarani if it’s disabled in the config then it’s not available to MagicMirror. It wouldn’t be able to show it at a scheduled time because it wouldn’t even be running.

    To do what you want to do is perhaps have a script that modifies your config, or replaces one config file with another that enables the module, then have it restart magic mirror. Schedule the script using a cron job. There are plenty of articles online that can help you write such a script and schedule it using cron.

    You can use the module scheduler as others suggest but it requires the module to be running even when it is hidden. Since you want it available only during the winter months, this means cpu cycles wasted during the summer. On a low powered device like the Pi, this could be a significant waste, especially if you have other modules that do a lot of heavy lifting.


  • Project Sponsor

    Dear j.e.f.f,

    thanks - this is really good to know and helpful advice.
    I am new to JS programming - but I am willing to tinker and learn. My current plan was to:

    • Add notification support to MMM-Snow analog to “USER_PRESENCE”
    • Add a config option to start inactive, e.g. “start_inactive:true”
    • Add a temp-file that stores the current state of “state_inactive” in case the system reboots.

    Then I could send a notification to MMM-Snow to set it active and inactive at the time needed. This might also be interesting for others…

    I had a look at other modules and hope, that I can pick up all necessary info from the way, these features have been implemented there.
    What do you think of this plan?


  • Project Sponsor Module Developer

    Sending and receiving notifications is the easy part of modules 🙂 Just look in a few of them and see how it works… you’ll pick right up on it!!


  • Module Developer

    @rudibarani
    Prepare two config - config.snowon.js and config.snowoff.js.
    Make a code to copy one of both to config.js when your trigger is activated. The next time rebooted, it will be applied.
    Instead of copying file, you can read config.js and rewrite it directly. but a bullet-proof-parsing js code is not so easy for unexperienced one.)

    However, MMM-Snow has no node_helper.js to refer. You have to build node_helper.js to do your job. (In MMM-Snow.js itself, approaching filesystem is limited.)


Log in to reply