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

    Posts

    Recent Best Controversial
    • RE: Motion Detector and OSX

      Icant post the entire code so, link to pastebin :)

      node_helper.js

      posted in Troubleshooting
      0
      0v3rNuLL
    • RE: Motion Detector and OSX

      Finally figured it out, this module now can put the screen off and on (osx el capitan).
      Here is the modification for node_helpder.js

      const NodeHelper = require("node_helper");
      
      const exec = require("child_process").exec;
      
      var cmd=require('node-cmd'); // install node-cmd (npm install node-cmd) first and add excute command osx style then change exec to cmd.get <-- return the result to analize
      
      module.exports = NodeHelper.create({
      	start: function () {
      		this.started = false;
      		this.isMonitorOn(function(result) {
      			console.log("MMM-MotionDetector: monitor on " + result);
      		});
      	},
      
      	activateMonitor: function () {
      		this.isMonitorOn(function(result) {
      			if (!result) {
      				cmd.get('caffeinate -u -t 1', function(err, out, code) {
      					if (err) {
      						console.error("MMM-MotionDetector: error activating monitor: " + code);
      					} else {
      						console.log("MMM-MotionDetector: monitor has been activated");
      					}
      				});
      			}
      		});
      		this.started = false;
      	},
      
      	deactivateMonitor: function () {
      		this.isMonitorOn(function(result) {
      			if (result) {
      				cmd.get('pmset displaysleepnow', function(err, out, code) {
      
      					
      					if (err) {
      						console.error("MMM-MotionDetector: error deactivating monitor: " + code);
      					} else {
      						console.log("MMM-MotionDetector: monitor has been deactivated");
      					}
      				});
      			}
      		});
      		this.started = false;
      	},
      
      	isMonitorOn: function(resultCallback) {
      
      
      
      		cmd.get('pmset -g powerstate IODisplayWrangler | tail -1 | cut -c29', function(err, out, code) {
      			console.log("MMM-MotionDetector: monitor " + out);
      
      			if (err) {
      				console.error("MMM-MotionDetector: error calling monitor status: " + code);
      				return;
      			}
      
      			console.log("MMM-MotionDetector: monitor " + out);
      		resultCallback(out.includes("4")); // <4 is off
      		});
      	},
      
      	// Subclass socketNotificationReceived received.
      	socketNotificationReceived: function (notification, payload) {
      		if (notification === "MOTION_DETECTED" && this.started === false) {
      			console.log("MMM-MotionDetector: MOTION_DETECTED, score " + payload.score);
      			this.started = true;
      			this.activateMonitor();
      		}
      		if (notification === "DEACTIVATE_MONITOR" && this.started === false) {
      			console.log("MMM-MotionDetector: DEACTIVATE_MONITOR");
      			this.started = true;
      			this.deactivateMonitor();
      		}
      	}
      });
      
      
      

      This can be marked as SOLVED :slightly_smiling_face:

      posted in Troubleshooting
      0
      0v3rNuLL
    • RE: Motion Detector and OSX

      hi sdetweil!

      I try on node_helper.js located on MMM-MotionDetector at the begining and did not work still getting display slep prevented by electron

      here is the part i change

      //////Original code/////
      
      const NodeHelper = require("node_helper");
      const exec = require("child_process").exec;
      ///////////////////
      
      const { powerSaveBlocker } = require('electron');
      
      const id = powerSaveBlocker.start('prevent-app-suspension'); 
      
      console.log(powerSaveBlocker.isStarted(id));
      
      powerSaveBlocker.stop(id)
      

      Its the correct place ?

      Sorry but im totally new on node.
      Thanks in advance

      posted in Troubleshooting
      0
      0v3rNuLL
    • Motion Detector and OSX

      hi everyone!
      I succesfully run MM2 on a macmini late 2009. Currently im testing some modules and so far so good except for one module Motion detector. I was looking on the code on node_helper.js and found the line with the command “vcgencmd display_power 0”.
      In OSX not work but “pmset displaysleepnow” to put the screen on sleep does the trick and " caffeinate -u -t 1" to wake up.
      So i replace the command

      if (result) {
      				exec("vcgencmd display_power 0", function(err, out, code) {
      					if (err) {
      						console.error("MMM-MotionDetector: error deactivating monitor: " + code);
      					} else {
      						console.log("MMM-MotionDetector: monitor has been deactivated");
      					}
      				});
      			}
      

      to

      if (result) {
      				exec("pmset displaysleepnow", function(err, out, code) {
      					if (err) {
      						console.error("MMM-MotionDetector: error deactivating monitor: " + code);
      					} else {
      						console.log("MMM-MotionDetector: monitor has been deactivated");
      					}
      				});
      			}
      

      Its looks like work but im getting this message on console log “pmset displaysleepnow blocked by app electron.js” and the screen keeps alive.

      Is there a way to solve this?
      Or maybe toggling the body to hide to get the black screen?

      Thanks in advance and sorry for my bad english :)

      posted in Troubleshooting
      0
      0v3rNuLL
    • MMM-Astrology language

      Hi every one!!
      Im starting with this awesome proyect making my own MM.
      Im runing it on an old macmini late 2009 with out a problem. So im testing some modules and the astrology seems to be intresting.
      My cuestion is :
      Its possible to change the language of results on it, Like spanish (my language) ?
      Or maybe can i host in some way my own server to pull out the data?

      Thanks in advance and sorry for my horrible english :P

      posted in Troubleshooting
      0
      0v3rNuLL
    • 1 / 1