• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
  1. Home
  2. andyb2000
  3. Posts
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
A
Offline
  • Profile
  • Following 0
  • Followers 0
  • Topics 2
  • Posts 3
  • Groups 0

Posts

Recent Best Controversial
  • RE: Module development node_helper.js config loading

    Aha, thank you that’s set me on the right path!

    It was indeed when calling it from another service, in this case a setInterval event was calling it which got it confused. Thanks for the suggestion on the newer callback, I solved it in the slightly older low-tech way:

    this.timer_socketforever = setInterval(()=>{
                            this.my_control(this.config)
                            }, 30000);
    
    

    So that the config info was passed as a parameter.
    Problem solved, thank you!

    posted in Development
    A
    andyb2000
    Mar 26, 2020, 1:31 PM
  • Module development node_helper.js config loading

    Hi folks,
    I’m writing a module at the moment and have most of it covered, except loading in my config, some functions seem able to access this.config and others don’t
    So first, I’m loading in config like this in node_helper.js:

            socketNotificationReceived: function(notification, payload) {
                    switch(notification) {
                            case "INIT":
                                    this.initConfigs(payload);
                            break
    
    initConfigs: function(config) {
                    this.config = config;
                    this.sendSocketNotification('INIT-DONE');
                    this.init = true;
            },
    
    

    And I send that from the main.js by doing:

    this.sendSocketNotification("INIT", this.config);
    

    Which works, so in most functions I can then call
    this.config.MyVariable and output it.
    However in some functions if I try and call the same variable, I get an exception error:

    [11:17:32.435] [ERROR]  TypeError: Cannot read property 'verbose' of undefined
    

    So it seems inconsistent.
    How would I define this.config in node_helper.js to be a global variable, should I change reference, move it to a var at the top of node_helpher.js and set it there rather than using the internal this. functions for variable definitions?
    Thanks in advance.

    posted in Development
    A
    andyb2000
    Mar 26, 2020, 11:33 AM
  • My test post

    Hi,
    I’m testing my posts after akismet had me flagged for spam. They’ve made some changes at akismet and hopefully I can now post!

    posted in General Discussion
    A
    andyb2000
    Mar 16, 2020, 11:35 AM
  • 1 / 1
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