sdetweil / MMM-SleepWake

module that uses an external source for motion detection, like a web camera
19 stars 0 forks source link

Module doesn't unhide or turn back on output #7

Open Dyldano opened 2 years ago

Dyldano commented 2 years ago

I've followed the default setup and changed the motion.conf file to match the start and end lines in the module config. However, the video files are being written to my /home/pi folder rather than the MMM-SleepWake/motion folder. I've also tried the hide and pi modes and I see the event stop action successfully trigger, however when the camera senses motion and writes a new file it doesn't start the even start action. I'm wondering if this is tied to the files being written to the wrong directory but hopefully you can provide more insight.

sdetweil commented 2 years ago

video files are controlled by another motion.conf setting.

you substituted the real values for the {userid} value, right?

on_event_start /home/{userid}/MagicMirror/modules/MMM-SleepWake/external_motion started

becomes this (if the logged on user for MM is the user pi)

on_event_start /home/pi/MagicMirror/modules/MMM-SleepWake/external_motion started

you should be able to execute those from the commandline too (while MM is running)

/home/pi/MagicMirror/modules/MMM-SleepWake/external_motion started and /home/pi/MagicMirror/modules/MMM-SleepWake/external_motion ended

/var/log/motion/motion.log is the motion process log file

you would see events in the log like this

1:ml1] [NTC] [ALL] [Jul 18 17:02:05] motion_detected: Motion detected - starting event 938
[1:ml1] [NTC] [ALL] [Jul 18 17:02:34] mlp_actions: End of event 938
[1:ml1] [NTC] [ALL] [Jul 18 17:03:00] motion_detected: Motion detected - starting event 939
[1:ml1] [NTC] [ALL] [Jul 18 17:03:17] mlp_actions: End of event 939
[1:ml1] [NTC] [ALL] [Jul 18 17:03:20] motion_detected: Motion detected - starting event 940
[1:ml1] [NTC] [ALL] [Jul 18 17:03:36] mlp_actions: End of event 940
[1:ml1] [NTC] [ALL] [Jul 18 17:03:55] motion_detected: Motion detected - starting event 941
[1:ml1] [NTC] [ALL] [Jul 18 17:04:11] mlp_actions: End of event 941
Dyldano commented 2 years ago

Yes I have those 2 values in the motion.conf set correctly. After running MM and sending the execute command for motion start after the content went into "hidden mode" the content came back correctly. So it seems the event_start value is not executing when motion is sensed on the camera, while the event_end value is executing correctly. I've reset the motion.conf file back to defaults minus the 2 modified lines to mitigate any other issues.

Here is a snippet of my log file: [1:ml1] [NTC] [ALL] [Jul 11 19:20:23] motion_detected: Motion detected - starting event 1 [1:ml1] [NTC] [ALL] [Jul 11 19:28:12] mlp_actions: End of event 1 [1:ml1] [NTC] [EVT] [Jul 11 19:28:19] event_newfile: File of type 8 saved to: /var/lib/motion/02-20220711192819.mkv [1:ml1] [NTC] [ALL] [Jul 11 19:28:19] motion_detected: Motion detected - starting event 2 [1:ml1] [NTC] [ALL] [Jul 11 19:29:49] mlp_actions: End of event 2 [1:ml1] [NTC] [EVT] [Jul 11 19:30:29] event_newfile: File of type 8 saved to: /var/lib/motion/03-20220711193028.mkv [1:ml1] [NTC] [ALL] [Jul 11 19:30:29] motion_detected: Motion detected - starting event 3 [1:ml1] [NTC] [ALL] [Jul 11 19:32:18] mlp_actions: End of event 3

sdetweil commented 2 years ago

can u show me the two lines from motion.conf?

copy/paste

Dyldano commented 2 years ago

on_event_start /home/pi/MagicMirror/modules/MMM-SleepWake/external_motion started

on_event_end /home/pi/MagicMirror/modules/MMM-SleepWake/external_motion ended

Timopen commented 9 months ago

There is a ")" missing on line 57 so the module is not working. if(module.name.startsWith("MMM-PIR-Sensor"){ should be: if(module.name.startsWith("MMM-PIR-Sensor")){

sdetweil commented 9 months ago

fixed, thanks

Dyldano commented 9 months ago

I've replicated this on another PI. According to the file manager, the detected & ended files are being modified in accordance to when motion detection starts & stops on the motion logs. I've also git pulled the most recent update, but the module does not bring the content out of the HIDE status.

sdetweil commented 9 months ago

@Dyldano can you turn on debug in the module config

debug: true, 

and restart mm.. i need to see the messages at MM startup time, npm start if you use pm2, then

pm2 logs --line=50

50 might need to be bigger

the module deletes the files as they show up...

so if there is constant motion there should be no files.. and end of motion the file will only be there for a second at most..

so, i think the problem is that they are owned by root, and not the user.. so maybe the user detection code is failing

go to the module motion folder and do

ls -laF
sdetweil commented 9 months ago

@Dyldano