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

    Posts

    Recent Best Controversial
    • RE: Even a simple node_help.js example does not run.

      @sdetweil

      {
        "name": "MMMTestpython",
        "description": "samples",
        "version": "0.0.1",
        "dependencies": {
          "python-shell": "latest"
        }
      }
      
      

      Do I have to change it like this and install it again? npm install

      0_1555077390063_231c85f3-9d06-4cd8-a2ec-fa08f4db34ee-image.png

      posted in Troubleshooting
      E
      emrhssla
    • RE: I don't know how to use node_helper.js.

      @sdetweil oh!!! 0_1555075761914_acdbfe01-9c20-45b9-a177-87d554b225e0-image.png
      thank you very very very much :)

      posted in Troubleshooting
      E
      emrhssla
    • RE: Even a simple node_help.js example does not run.

      @sdetweil said in Even a simple node_help.js example does not run.:

      console.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);

      var NodeHelper = require("node_helper");
      //var {PythonShell} = require('python-shell');
      
      module.exports = NodeHelper.create({
        start: function() {},
        
        socketNotificationReceived: function(notification, payload) {
          console.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
        },
      })   
      

      0_1555075600760_f2b5f62a-75bc-48ea-9a97-7c88d676b3d5-image.png
      omg…

      posted in Troubleshooting
      E
      emrhssla
    • RE: Even a simple node_help.js example does not run.

      @sdetweil 0_1555074987553_d58a7d49-677c-4048-a9e4-709a574bc29a-image.png

      Is it normal for these errors to occur?
      /modules/MMM-Testpython/package.json

      posted in Troubleshooting
      E
      emrhssla
    • Even a simple node_help.js example does not run.

      MMM-Testpython

      var Testpythons;
      Module.register("MMM-Testpython", {
      
          defaults: {},
          start: function (){
              Testpythons = this;
          },
        
        getDom: function() {
          var element = document.createElement("div")
          element.className = "myContent"
          element.id="divid"
          element.innerHTML = "Hello, World!!! " + this.config.foo
          var subElement = document.createElement("p")
          subElement.innerHTML = "Click" 
          subElement.id = "clickid"
          element.appendChild(subElement)
          return element
        },
        
        notificationReceived: function(notification, payload, sender) {
          switch(notification) {
            case "DOM_OBJECTS_CREATED":
            var elem = document.getElementById("clickid")
            elem.addEventListener("click", () => {
              Testpythons.sendSocketNotification("TEST")
              console.log("hello~hello~hello~hello~hello~hello~hello~hello~hello~hello~")
              elem.innerHTML = "click success"       
            }) 
              break
          }
        },
        
      })
      

      node_helper.js

      var NodeHelper = require("node_helper");
      var {PythonShell} = require('python-shell');
      
      module.exports = NodeHelper.create({
        start: function() {},
        
        socketNotificationReceived: function(notification, payload) {
          switch(notification) {
            case "TEST":
              console.log("notification : " + notification)
              this.sendSocketNotification("I_DID")
              break
          }
        },
      })  
      

      0_1555061178870_43ed7384-d4d5-4421-8c6b-a664582b6883-image.png
      0_1555061131673_64d4b79c-9344-4c93-9f4f-31ed55371eca-image.png
      The notification I_DID in node_helper.js was well communicated and executed. However, the console in node_helper.js is not output…
      What is the problem?

      var NodeHelper = require("node_helper");
      var {PythonShell} = require('python-shell');
      
      module.exports = NodeHelper.create({
        start: function() {},
        
        socketNotificationReceived: function(notification, payload) {
          Log.log(this.name + " received a socket notification: " + notification + " - Payload: " + payload);
          
        },
      })  
      

      0_1555061311849_80e6e224-4ff0-45e5-89e5-93ad49f7cc0d-image.png

      0_1555061325787_4d1587ba-527f-4a4c-92c0-8c5c5b1dbff7-image.png

      Even a simple node_help.js example does not run.

      posted in Troubleshooting
      E
      emrhssla
    • RE: I don't know how to use node_helper.js.

      @sdetweil

      var NodeHelper = require("node_helper");
      var {PythonShell} = require('python-shell');
      
      module.exports = NodeHelper.create({
        start: function() {
          console.log("Starting module: " + this.name);
        },
        
        socketNotificationReceived: function(notification, payload) {
          console.log("Starting module: " + this.name);
          switch(notification) {
            case "TESTPYTHON":
              console.log("notification : " + notification)
              this.sendSocketNotification("I_DID")
              PythonShell.runString('print("Hello Python")', null, function (err, result) {
                  if (err) throw err;
                  console.log(result);  
                  });
              break
          }
        },
      })  
      

      0_1555054288241_a49a1a4e-d8c3-4e5c-8463-81b9df38737c-image.png

      console doesnt show Starting module…

      posted in Troubleshooting
      E
      emrhssla
    • I don't know how to use node_helper.js.

      I tried to use python-shell. So I successfully finished the npm install python-shell.
      But I saw it said that to use python-shell, you must use node_helper.js.
      So I tried to execute a simple Python code. The notification I_DID in node_helper.js was well communicated and executed. However, the console in node_helper.js is not output, nor is python-shell working.
      What is the problem?

      var Testpythons;
      Module.register("MMM-Testpython", {
      
          defaults: {},
          start: function (){
              Testpythons = this;
          },
        
        getDom: function() {
          var element = document.createElement("div")
          element.className = "myContent"
          element.id="divid"
          element.innerHTML = "Hello, World!!! " + this.config.foo
          var subElement = document.createElement("p")
          subElement.innerHTML = "Click" 
          subElement.id = "clickid"
          element.appendChild(subElement)
          return element
        },
        
        notificationReceived: function(notification, payload, sender) {
          switch(notification) {
            case "DOM_OBJECTS_CREATED":
            var elem = document.getElementById("clickid")
            elem.addEventListener("click", () => {
              Testpythons.sendSocketNotification("TESTPYTHON")
              console.log("hello~hello~hello~hello~hello~hello~hello~hello~hello~hello~")
              elem.innerHTML = "click success"
              
            }) 
              break
          }
        },
        socketNotificationReceived: function(notification, payload) {
          switch(notification) {
            case "I_DID":
              console.log("success")
              var elemk = document.getElementById("divid")
              elemk.innerHTML = "I_DID"
              break
          }
        },
      })
      

      node_helper.js

      var NodeHelper = require("node_helper");
      var PythonShell = require('python-shell');
      
      module.exports = NodeHelper.create({
        start: function() {
          console.log("Starting module: " + this.name);
        },
        
        socketNotificationReceived: function(notification, payload) {
          switch(notification) {
            case "TESTPYTHON":
              console.log("notification : " + notification)
              this.sendSocketNotification("I_DID")
              PythonShell.runString('print("Hello Python")', null, function (err, result) {
                  if (err) throw err;
                  console.log(result);  
                  });
              break
          }
        },
      })  
      
      posted in Troubleshooting
      E
      emrhssla
    • RE: How can I change the variable value of the config after the magic mirror is run? I want to change the config of MMM-embedYoutube through MMM-Modulebar.

      @sdetweil success using notification! thank you!

      posted in Troubleshooting
      E
      emrhssla
    • 1
    • 2
    • 3
    • 4
    • 5
    • 4 / 5