MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. andyb2000
    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

    andyb2000

    @andyb2000

    North-East, UK. Senior Network Engineer for an ISP. Spare time developer on various projects.

    0
    Reputation
    36
    Profile views
    3
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online
    Age 45
    Location North-East, UK

    andyb2000 Unfollow Follow

    Latest posts made by andyb2000

    • 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
    • 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
    • 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