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

    jmagsumbol

    @jmagsumbol

    0
    Reputation
    398
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    jmagsumbol Unfollow Follow

    Latest posts made by jmagsumbol

    • RE: node_helper and python communication

      @ninjabreadman yap python_start is called by an event from the modules (script is not complete)
      In the MMM-PIR-Sensor the GPIO is used. In my case I would like to use usb. So i should require node-serial port. That’s what one way I can try it.
      But I also thought of doing the complete logic, like switching on/off the screen, in my python script. So the only job of the module is to call python.

      posted in Troubleshooting
      J
      jmagsumbol
    • node_helper and python communication

      Hi,

      I have started to dig in developing own modules. I wanted to use an ultrasonic sensor to check if a person is in front of the mirror minimum 100cm. In this case the python script sends a ‘message’ with a type event and distance in cm. This should turn off the screen. Then a timer (5sec) starts to switch off the screen again as long as there is no message coming in.

      I have several problems and don’t know why:

      1. the timer never starts
      2. my console logs are only displayed AFTER the magic mirror app is stopped.

      Can anyone give me a hint? Or is there a better implementation for the communication between python and the modules?

      module.exports = NodeHelper.create({
      
          python_start: function() {
          		pyshell = new PythonShell('serialDistance.py');
      
          		pyshell.on('message', function (message) {
          		  console.log(message);
          			self.switchScreenOn();
          		});
          },
          switchScreenOff: function(){
          	console.log("Switch screen off");
          	clearInterval(timer);
          },
          switchScreenOn: function(){
          	var self = this;
            console.log("Switch screens on");
          	timer = setInterval(self.switchScreenOff, 5000);
          },
      })
      
      posted in Troubleshooting
      J
      jmagsumbol