MMM-Remote-Control {fix monitor on/off} tvservice --> vcgencmd



  • As was documented in this 8 month old thread, users having issues with the screen remaining blank after a MONITORON event solved the problem by replacing the exec statement to tvservice to instead exec vcgencmd in node_helper.js.

    The below solution was posted -
    Change:

    activateMonitor: function () {
        if (this.config.turnOffDisplay) {
          // Check if hdmi output is already on
          exec("/opt/vc/bin/tvservice -s").stdout.on("data", function(data) {
            if (data.indexOf("0x120002") !== -1)
              exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null);
          });
        }
      },
    
      deactivateMonitor: function () {
        if (this.config.turnOffDisplay) {
          exec("/opt/vc/bin/tvservice -o", null);
        }
      },
    

    WIth:

     activateMonitor: function () {
       if (this.config.turnOffDisplay) {
         // Check if hdmi output is already on
         exec("vcgencmd display_power 1").stdout.on("data", function(data) {
           if (data.indexOf("0x120002") !== -1)
             exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null);
         });
       }
     },
    
     deactivateMonitor: function () {
       if (this.config.turnOffDisplay) {
         exec("vcgencmd display_power 0", null);
       }
     },
    

    However, the node_helper.js language has now changed since the above post to now be:

    		if (query.action === "MONITORON")
    		{
    			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")
    		{
    			exec("tvservice -o", opts, function(error, stdout, stderr){ self.checkForExecError(error, stdout, stderr, res); });
    			return true;
    		}
    

    I’ve little experience with js coding, and wondered if anyone had already updated the above vcgencmd calls to work with the now current node_helper language? Or if someone could suggest what that language would now be so I don’t break anything ignorantly futzing around?

    (Of course, the optimum would be to have a config option officially added to Remote-Control to have the option of using tvservice (as the default), or vcgencmd for those of us that tvservice doesn’t work so well for…)

    Many thanks for any help provided.

    (Using RPI Zero W / Raspbian Stretch Lite / Dell monitor via HDMI / serveronly mode)



  • I should have searched around. This was recently solved with a fork by BKeyport to Remote-Control here.