@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.
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.
Read the statement by Michael Teeuw here.
J
Latest posts made by jmagsumbol
-
RE: node_helper and python communication
-
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:
- the timer never starts
- 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); }, })