From 72429236c4061c40b54c8432813529c8f767424e Mon Sep 17 00:00:00 2001 From: AgP42 Date: Mon, 23 Jul 2018 09:06:40 +0200 Subject: [PATCH] Bug correction and new functionnalities Bug correction for Brightness control : https://github.com/Jopyth/MMM-Remote-Control/issues/76 New functionnalities : - add a Notification to others modules names "USER_PRESENCE" to true or false when MONITORON or MONITOROFF are requested - possibility to send this Notification "USER_PRESENCE" to true or false by other module request (for example, I use MMM-Navigation to send USER_PRESENCE to true to allow my module update on request) This notification "USER_PRESENCE" can also be send by the module MMM-PIR-Sensor. --- node_helper.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/node_helper.js b/node_helper.js index d0e509a..af5fd27 100644 --- a/node_helper.js +++ b/node_helper.js @@ -593,13 +593,30 @@ module.exports = NodeHelper.create({ }); return true; } + if (query.action === "USER_PRESENCE") + { + //Add AgP + this.sendSocketNotification("USER_PRESENCE", query.value); + // console.log("User presence true"); + + return true; + } if (query.action === "MONITORON") - { + { + //Add AgP + this.sendSocketNotification("USER_PRESENCE", true); + // console.log("User presence true"); + exec("tvservice --preferred && sudo chvt 6 && sudo chvt 7", opts, function(error, stdout, stderr){ self.checkForExecError(error, stdout, stderr, res); }); return true; } if (query.action === "MONITOROFF") { + + //Add AgP + this.sendSocketNotification("USER_PRESENCE", false); + // console.log("User presence false"); + exec("tvservice -o", opts, function(error, stdout, stderr){ self.checkForExecError(error, stdout, stderr, res); }); return true; } @@ -615,8 +632,12 @@ module.exports = NodeHelper.create({ } if (query.action === "BRIGHTNESS") { - res.send({"status": "success"}); + //Modif AgP + //res.send({"status": "success"}); + if (res) {res.send({"status": "success"}); } + self.sendSocketNotification(query.action, query.value); + return true; } if (query.action === "SAVE")