Modules starting hidden.



  • 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


  • Module Developer

    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.


Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.