• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Motion Detector

Scheduled Pinned Locked Moved Utilities
213 Posts 38 Posters 453.1k Views 39 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    pepemujica @danielis
    last edited by May 23, 2017, 6:46 PM

    @danielis said in Motion Detector:

    ur problem is that as soon as the mirror is off, your monito

    Yes sir, that is my problem, the module seems to be working fine, but it is a bit annoying to see the alert when the mirror is off

    1 Reply Last reply Reply Quote 0
    • D Offline
      danielis
      last edited by yawns Jul 17, 2017, 7:35 AM May 24, 2017, 3:36 PM

      Yes, that was what I tried to say in my first post yesterday.
      I had the same problem.
      Old monitors do not turn off by themselve if there is no signal. Newer monitor do turn off, and all is fine.

      My solution was tu use a relais to turn on/off the current of the monitor. Therefore I used a pin of the GPIOs to control the relais.

      For controlling this GPIO pin I used the wiringpi library

      I had to add some lines in the node_helper.js - please look at the lines with: exec("gpio -g …

      pi@magicmirror:~/MagicMirror/modules/motiondetector $ more node_helper.js

      'use strict';
      
      /* Magic Mirror
       * Module: MMM-PIR-Sensor
       *
       * By Paul-Vincent Roll http://paulvincentroll.com
       * MIT Licensed.
       */
      
      const NodeHelper = require('node_helper');
      const exec = require('child_process').exec;
      var moment = require('moment');
      
      module.exports = NodeHelper.create(
      {
        start: function ()
        {
              //this.started = false;
              exec("gpio -g write 4 1", null);
              console.log('motiondetector started ...');
              console.log('monitor relais on');
        },
        activateMonitor: function ()
        {
              exec("gpio -g write 4 1", null);
              console.log(moment().format() + ' monitor relais on');
              //this.started = false;
        },
        deactivateMonitor: function ()
        {
              exec("gpio -g write 4 0", null);
              console.log(moment().format() + ' monitor relais off');
              //this.started = false;
        },
        socketNotificationReceived: function (notification)
        {
            //const self = this;
            if (notification === 'MOTION_DETECTED')
            {
                //const self = this;
                //this.started = true;
                this.activateMonitor();
            }
            if (notification === 'DEACTIVATE_MONITOR')
            {
                //const self = this;
                //this.started = true;
                this.deactivateMonitor();
            }
        }
      } );
      
      P 1 Reply Last reply Jun 2, 2017, 4:41 PM Reply Quote 0
      • P Offline
        pepemujica @danielis
        last edited by Jun 2, 2017, 4:41 PM

        @danielis Hi! I’ve tried, but still can’t get it. So I was thinking, instead of putting of the monitor, is it possible to show a black image for example?
        So when it detects movement, the MM appears, and when not, a black photo is shown.
        Is it possible?

        Y 1 Reply Last reply Jun 2, 2017, 8:06 PM Reply Quote 0
        • Y Offline
          yawns Moderator @pepemujica
          last edited by Jun 2, 2017, 8:06 PM

          @pepemujica
          There is a module called HideAll (or something similar) which simply hides all modules and leaves a black background. Maybe you want to try it

          1 Reply Last reply Reply Quote 2
          • K Offline
            Kimzer
            last edited by Jun 28, 2017, 9:07 PM

            Could someone please write up a working instruction for the motion detector with the rasperry pi camera? Not the pir sensor, need to make use of the camera somehow. :)

            B 1 Reply Last reply Jul 6, 2017, 10:48 PM Reply Quote 1
            • M Offline
              mickyas @alexyak
              last edited by Jul 6, 2017, 8:33 PM

              @alexyak Does this module switch off the pi, i’m only asking since i have Alexa running in the background which requires 3 terminals to be open all the time? If the pi goes into ‘standby’ or goes off i have to re-enter the information into the 3 terminals consecutively to get it up and running again. Thanks
              Mick

              1 Reply Last reply Reply Quote 0
              • B Offline
                bhepler Module Developer @Kimzer
                last edited by Jul 6, 2017, 10:48 PM

                @Kimzer I wrote up a method using a version of Motion for the RasPi. It’s under the tutorials section of the forum. It’s a non-module solution, so there’s some weirdness involved. But I did get it to work with a Raspicam.

                @mickyas - This module doesn’t switch off the pi, it just switches off the output to the monitor.

                C 1 Reply Last reply Jul 6, 2017, 10:58 PM Reply Quote 2
                • C Offline
                  cowboysdude Module Developer @bhepler
                  last edited by Jul 6, 2017, 10:58 PM

                  @bhepler Yup that’s what I did too.

                  1 Reply Last reply Reply Quote 1
                  • H Offline
                    Hawking
                    last edited by Hawking Jul 16, 2017, 5:57 PM Jul 16, 2017, 5:32 PM

                    I’m trying to use this model on my Raspberry Pi Zero W with the Raspberry Cam. I run
                    MM in serveronly mode, using the Midori-browser. This setup itself works fine and also the camera is able to make pictures

                    raspistill -o testpicture.jpg
                    

                    However, if I try to add the ‘motiondetector’ module to the config I just get an empty (black, but not switched of) screen after reboot. This is even the case for a very small config.js :

                    var config = {
                            port: 8080,
                            ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
                            language: "en",
                            timeFormat: 24,
                            units: "metric",
                    
                            modules: [
                                    {
                                            module: "clock",
                                            position: "top_left"
                                    },
                                {
                                        module: 'motiondetector',
                                        config: {
                                                timeout: 5*60*1000
                                        }
                                },
                            ]
                    
                    };
                    
                    /*************** DO NOT EDIT THE LINE BELOW ***************/
                    if (typeof module !== "undefined") {module.exports = config;}
                    

                    Things I did:

                    cd ~/MagicMirror/modules
                    git clone https://github.com/alexyak/motiondetector
                    

                    Added line bcm2835-v4l2 to /etc/modules and hdmi_blanking=1 to /boot/config.txt

                    If I omit the motiondetecotor entry in the config.js it loads fine and I can see the loaded modules. If I execute

                    /opt/vc/bin/tvservice -o
                    

                    the screen goes off (completely black). I I afterwards run

                    /opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 7
                    

                    the background light of the screen goes on, however the modules that were there previously don’t show up again ( I waited for several minutes).
                    If I run

                    /opt/vc/bin/tvservice --preferred && sudo chvt 6 && sudo chvt 2
                    

                    the modules become visible again. Therefore I changed the line in

                    ~/MagicMirror/modules/motiondetector/node_helper.js
                    

                    accordingly. However then I got still an empty screen and in the log:

                    Jul 16 18:59:23 me startMagicMirror.sh[480]: ** Message: console message: [native code] @0: Starting module: motiondetector
                    Jul 16 18:59:23 me startMagicMirror.sh[480]: ** Message: console message: http://localhost:8080/modules/motiondetector//motiondetector.js @39: TypeError: Attempted to assign to readonly property.
                    Jul 16 18:59:24 me startMagicMirror.sh[480]: monitor :state 0x12000a [HDMI DMT (82) RGB full 16:9], 1920x1080 @ 60.00Hz, progressive
                    Jul 16 18:59:24 me startMagicMirror.sh[480]: ** Message: console message: http://localhost:8080/js/main.js @134: TypeError: null is not an object (evaluating 'moduleWrapper.getElementsByClassName')
                    

                    To me as a beginner it looks like a permission problem. However even making the motiondetector folder and all files therein rw for everybody it didn’t work.

                    I hope that somebody who has knowledge about JS can comment on this issue. Many thanks in advance.

                    strawberry 3.141S 1 Reply Last reply Jul 17, 2017, 5:59 AM Reply Quote 0
                    • strawberry 3.141S Offline
                      strawberry 3.141 Project Sponsor Module Developer @Hawking
                      last edited by Jul 17, 2017, 5:59 AM

                      @Hawking try to change line 39 to:

                      cameraPreview.style.visibility = "hidden";
                      

                      Please create a github issue if you need help, so I can keep track

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 15
                      • 16
                      • 17
                      • 18
                      • 19
                      • 20
                      • 21
                      • 22
                      • 17 / 22
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy