Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    Modules starting hidden.

    Troubleshooting
    2
    2
    2033
    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.
    • N
      number1dan last edited by

      Hello there. I would like to know if there’s an easy way for a module to be ready but hidden. My particular case is having a module hidden until i give the voice command to show itself. All my voice commands work and I have achieved what i wanted in terms of it being hidden but it feels a bit convoluted and am wondering if there was an easier way. It will probably be best if I write what I’ve done.

      Module in question: MMM-Instagram
      Voice Module: MMM-voice

      As soon as the Instagram module received the ALL_MODULES_STARTED notification and has sent the REGISTER_VOICE_MODULE notification I’ve asked it to also send a socket notification INITIAL_HIDE. the node_helper.js then receives and literally sends INITIAL_HIDE straight back and then i have an “if socketnotification INITIAL_HIDE received then hide()”. In my inexperienced minds opinion, this makes the Instagram module ready and available to the voice module but hides before instagram pictures start showing up. Is there a more efficient way of doing this?

      I can clarify if I’ve not been clear. I’m quite new to this, the only experience with javascript I’ve had before is writing simple parsing scripts for a SIEM tool at my old work.

      Thanks,
      Dan

      1 Reply Last reply Reply Quote 2
      • Cato
        Cato Module Developer last edited by Cato

        I struggled with the same until I came up with the pattern I’m using in my MotionEye module (see link to GitHub in my signature).

        In the module I configure a global variable ‘motionDetected’ (could be named 'visible’) that I set to false. In the ‘getDom’ function I return only a DOM element if that is true.

        In the node _ helper I send SHOW notification to the module whenever I want the module to be visible. I do this initially in ‘start’ function too because the user can configure the module to be visible at start. This is not necessary if it always should start hidden.

        Back in the module, I receive the notification and updates the ‘visible’ variable and call updateDom that now will return something.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy