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

    grantc66

    @grantc66

    1
    Reputation
    458
    Profile views
    19
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    grantc66 Unfollow Follow

    Best posts made by grantc66

    • RE: RPI4 Dual Monitor blanking

      For anyone having this issue:

      Change the kms driver to the fake one by editing /boot/config.txt

      change

      dtoverlay=vc4-kms-v3d
      

      to

      dtoverlay=vc4-fkms-v3d
      

      Reboot & display will now switch on/off using

      vcgencmd display_power 0
      vcgencmd display_power 1
      

      I’ve not noticed any problems using the fake driver but I’m not using anything 3D (your results may be different)

      posted in Troubleshooting
      G
      grantc66

    Latest posts made by grantc66

    • RE: RPI4 Dual Monitor blanking

      For anyone having this issue:

      Change the kms driver to the fake one by editing /boot/config.txt

      change

      dtoverlay=vc4-kms-v3d
      

      to

      dtoverlay=vc4-fkms-v3d
      

      Reboot & display will now switch on/off using

      vcgencmd display_power 0
      vcgencmd display_power 1
      

      I’ve not noticed any problems using the fake driver but I’m not using anything 3D (your results may be different)

      posted in Troubleshooting
      G
      grantc66
    • RE: RPI4 Dual Monitor blanking

      @grantc66

      For anyone having the same issue:

      Another solution is to edit /boot/config.txt & change to the fake kms driver

      dtoverlay=vc4-kms-v3d
      

      to

      dtoverlay=vc4-fkms-v3d
      

      reboot & then

      vcgencmd display_power 0
      vcgencmd display_power 1
      

      work as they used to do.

      I’ve not noticed any negative effect from using the fake one but I’m not using any 3D effects (your results may vary).

      posted in Troubleshooting
      G
      grantc66
    • RE: RPI4 Dual Monitor blanking

      After nearly a week of trying different things, short of removing the KMS driver or reverting to Buster, the only method I could come up with was to use the xset screensaver.

      Set the timeout to 3 minutes
      xset -display :0 s 180
      and do
      xset -display :0 s reset
      to wake it up on motion.

      It’s not elegant but without any cec control of the monitor it appears to be my only solution, unless anyone has a method to get xrandr to keep electron on the correct monitor.

      posted in Troubleshooting
      G
      grantc66
    • RE: RPI4 Dual Monitor blanking

      @wishmaster270 Thanks for the suggestion. Unfortunately not a timing issue.

      Adding a delay didn’t change the behaviour. ☹️

      posted in Troubleshooting
      G
      grantc66
    • RPI4 Dual Monitor blanking

      Started a new project with a dual monitor setup using a pi4. Connected via DVI as there is no HDMI (only display port, thanks HP).

      Monitors are in portrait mode & MM is setup in single instance configuration using this post as a template (linky)

      The latest version of Bullseye seems to have stopped “vcgencmd display_power 0” from working , it no longer blanks the display and just responds with display_power=1. This appears to be due to a change to the KMS driver.

      Googling give me this as an alternative

      xrandr --output HDMI-1 --off
      

      It does work & switches the screens off (separate commands for HDMI-1 & HDMI-2) however, using

      xrandr --output HDMI-2 --off
      xrandr --output HDMI-1 --off
      

      to switch off and

      xrandr --output HDMI-1 --rotate right --auto
      xrandr --output HDMI-2 --rotate left --right-of HDMI-1 --auto
      

      Puts them back in the right place . Sometimes.
      About 1 in every 10 off/on cycles the righthand display ends up on HDMI-1 & HDMI-2 shows the desktop. CTRL W puts it back in the right place, but that’s really annoying & I don’t want to reset the MM every time as it looks ugly whilst repopulating.

      Has anyone found a more reliable method to blank the displays & return MM back to the correct displays?

      posted in Troubleshooting
      G
      grantc66
    • Running Python under node.js

      Hi,

      A few weeks ago I started looking into getting notifications onto the mirror from python. Whilst it was relatively straight forward to run python within a shell from the node-helper, I ran into various problems with user privileges and environments.

      To get around this I had a play with rabbitmq. Using amqp for the node end and pika for the python. This opens up a whole world of possibilities for my mirror without having to learn javascript (above the basics & plagiarising code snippets from the built in modules) .

      node-helper end looks like. Sorry it’s a bit messy & I went overboard on the error capture.

      var amqp = require("amqplib/callback_api");
      
      PStart: function starter() {
      const self = this;
        amqp.connect("amqp://localhost", function(err, conn) {
          if (err) {
            console.error("[AMQP]", err.message);
            return setTimeout(starter, 1000);
          }
          conn.on("error", function(err) {
            if (err.message !== "Connection closing") {
              console.error("[AMQP] conn error", err.message);
            }
          });
          conn.on("close", function() {
            console.error("[AMQP] reconnecting");
            return setTimeout(starter, 1000);
          });
          console.log("[AMQP] connected");
          amqpConn = conn;
      
        amqpConn.createChannel(function(err, ch) {
          if (closeOnErr(err)) return;
          ch.on("error", function(err) {
            console.error("[AMQP] channel error", err.message);
          });
          ch.on("close", function() {
            console.log("[AMQP] channel closed");
          });
      
          ch.prefetch(10);
          ch.assertQueue("message", { durable: false }, function(err, _ok) {
            if (closeOnErr(err)) return;
            ch.consume("message", function(msg) {
      try {
       var fp = JSON.parse(msg.content.toString());
          ch.ack(msg);
          } catch (e) {
            closeOnErr(e);
          }
                      if (fp[0].data == "data"){
                      self.sendData({"PlrStat": fp[0].PlrStat, "TrkNxt":fp[0].TrkNext, "Station": fp[0].Station, "Said": fp[0].Said);
                      } else if (fp[0] == "status") {
                      console.log("[MMM-Radio]" + fp[0].status);
                      } else {
                      console.log("Got something");
                      console.log(msg);
                      console.log(fp[0].data);}
      })}, { noAck: false });
            console.log("Worked");
            });
      });
      }  });
      
      function closeOnErr(err) {
        if (!err) return false;
        console.error("[AMQP] error", err);
        amqpConn.close();
        this.Pstart();
        return true;
      }
      
      

      Python end:

      import pika
      
      def to_node(message):
          try:
              channel.basic_publish(exchange='',
                                    routing_key='message',
                                    body=json.dumps(message))
          except Exception:
              connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
              channel = connection.channel()
              channel.queue_declare(queue='message')
              channel.basic_publish(exchange='',
                                    routing_key='message',
                                    body=json.dumps(message))
      
      

      The bit in the exception is the initial setup for the connection, it does occasionally time out so re-establish if the publishing doesn’t work.

      Some useful tutorials on rabbitmq can be found here

      Hope this is a help to some of you who know very little about js & do all the complicated stuff with other languages.

      posted in General Discussion
      G
      grantc66
    • RE: Snowbound on node.js

      @sean Looks like I’ll be learning how to program in Java script :)

      Thanks for the tips.

      BTW: I found the issue with the python not running, seems the call from node changes the name of the script so main () had a different name to the import. Didn’t cure the snowboy issue (at least it got called, didn’t respond to wake word though 🤔, I’ll ask on the snowboy forum why that might be), but everything else worked.

      posted in Troubleshooting
      G
      grantc66
    • RE: Snowbound on node.js

      @sdetweil Thanks, had it in there for the pythonshell forgot about it on this version.

      Any pointers on trying exec, my googlefoo is failing to find any help.

      posted in Troubleshooting
      G
      grantc66
    • RE: Snowbound on node.js

      @sean said in Snowbound on node.js:

      MMM-Hotword

      Tried that, it works but its very slow to respond. With the python script, you can say the hotword and give it instructions seamlessly, passing notifications to seems to take forever to respond.

      What I’m trying to get to is understanding what node is doing with the python that stops external modules working & hopefully find away around it. Bit more of a learning exercise, if I can crack this it’ll open up my ability to expand the functionality.

      posted in Troubleshooting
      G
      grantc66
    • RE: Snowbound on node.js

      Got it launching with spawn, the code without snowboy works well (have an issue with getting status messages passed, but I’ll fix that later)

      The version using the snowboy listener works until the snowboy decoder call. Then it stalls, doesn’t crash just freezes. Like the code is running but not communicating back to the python script.

      Couldn’t find anything on exec, this is the spawn version.

      node_helper.js

      const NodeHelper = require("node_helper");
      const spawn = require("child_process").spawn;
      var pythonStarted = false
      
      module.exports = NodeHelper.create({
      
      	socketNotificationReceived: function(notification, payload) {
      		if (notification === "MMM-PIRadio-NOTIFICATION_TEST") {
      			console.log("Working notification system. Notification:", notification, "payload: ", payload);
      
      			this.sendNotificationTest(this.anotherFunction()); //Is possible send objects :)
      		}
      		if (notification === "CONFIG") {
      			console.log("Got a request to start Python:", notification, "payload: ", payload);
      				if(!pythonStarted) {
      					pythonStarted = true;
      					this.python_start();
      				}
      		}
      	},
      
      	sendNotificationTest: function(payload) {
      		this.sendSocketNotification("MMM-PIRadio-NOTIFICATION_TEST", payload);
      	},
      	
      	sendData: function(payload) {
      		this.sendSocketNotification("PiRadiodata", payload);
      	},
      
      	extraRoutes: function() {
      		var self = this;
      		this.expressApp.get("/MMM-PIRadio/extra_route", function(req, res) {
      			// call another function
      			values = self.anotherFunction();
      			res.send(values);
      		});
      	},
      	python_start: function () {
      		const self = this
      
                      const callPy = spawn("/usr/bin/python3.5",["./modules/MMM-PIRadio/PiRadioSnow.py"]);
                      callPy.stdout.on('message', function (message) {
      
      			if (message.hasOwnProperty('status')){
      			console.log("[" + self.name + "]" + message.status);
      			}
      
      			if (message.hasOwnProperty('data')){
      			console.log("[" + self.name + "]" + message.data.PlrStat + " : " + message.data.Station + " : " + message.data.Said + " : " + message.data.volume);
      			self.sendData({"PlrStat": message.data.PlrStat, "TrkNxt":message.data.TrkNext, "Station": message.data.Station, "Said": message.data.Said, "volume": message.data.volume});
      			}
      		});
      
      	},
      
      });
      

      What am I doing wrong? Sorry about the formatting.

      posted in Troubleshooting
      G
      grantc66