script turns off camera while I'm home

360 views
Skip to first unread message

Pascal GUILLAUME

unread,
Mar 11, 2021, 5:25:52 AM3/11/21
to motioneye

Hello,

I am using MotionEye with a Raspberry Pi 3B and a Microsoft LifeCam HD-5000 camera.

Is there a feature in MotionEye or a script to turn off the camera if someone in the household is home and turn the camera back on when everyone is gone?

I would like to use the detection of the cell phone IP address of family members.

I am new to Linux and am unable to write this script myself.

Kevin Shumaker

unread,
Mar 11, 2021, 6:34:21 AM3/11/21
to Pascal GUILLAUME, motioneye
There are a number of variables here:
How many to check for?
How often to check?
Are they set up with static IPs?
How would you 'guarantee' that they are the 'real' phones of the residents? (not someone 'spoofing'

Is the system capable? Yes
Is there a script available? Not that I am aware of.


--
You received this message because you are subscribed to the Google Groups "motioneye" group.
To unsubscribe from this group and stop receiving emails from it, send an email to motioneye+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/motioneye/430eba0b-c8af-47cb-baf6-117448fc3004n%40googlegroups.com.


--
Thanks

Kevin Shumaker


N38° 19' 56.52"
W85° 45' 8.56"

Semper Gumby
“Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
Ethics are what we do when no one else is looking.
Quis custodiet ipsos custodes?
“There is no end to the good you can do if you don’t care who gets the credit.” - C Powell
You know we're sitting on four million pounds of fuel, one nuclear weapon and a thing that has 270,000 moving parts built by the lowest bidder. Makes you feel good, doesn't it?
Message has been deleted

Pascal GUILLAUME

unread,
Mar 11, 2021, 7:50:31 AM3/11/21
to motioneye
Hello, and thank you for your response.
There would be 2 phones to watch. I can assign them a fixed IP address. It would be necessary to check every minute for example.
I don't know how to guarantee that these are the real phones except with the MAC address ... but if that complicates things too much I will ignore this feature.

Kevin Shumaker

unread,
Mar 11, 2021, 8:02:52 AM3/11/21
to Pascal GUILLAUME, motioneye
It would seem to me to be a security issue. MAC addresses (both WiFi and bluetooth) can be spoofed, too.
There is the port 7999 ability to pause recording and resume recording, which can be used for your purpose, but is not secure.
There are IoT devices out there, like my Honeywell T5 thermostat for my heating and air conditioning that does geofencing but all that involves is setting my house temperature a bit higher or lower if I am at home or near home. It also notifies me if I am inside or outside the geofence. Turning on or off security cameras via a similar method could be 'bad'. in the event a bad guy gets to shut down your recoding. What if the camera would have recorded a robbery or invasion, but the camera was off because your phone was there? I edit recordings (delete or save elsewhere) all the time (at least weekly). as needed. I use privacy mask on some parts of video, use the pause/resume as needed, etc.


Pascal GUILLAUME

unread,
Mar 12, 2021, 2:34:11 AM3/12/21
to motioneye
Sorry for the Google translations, I'm not very good at English.

I want to automate otherwise I will definitely forget to reconnect the camera. I wish I didn't have to deal with it all the time, just check that the system is working every now and then.

I don't live in a wealthy neighborhood, a big-name hacker is unlikely to impersonate me, but I'm warned and aware of the risk now.

I don't want the camera to record me all day even though it's mine. In addition it will take up space and create a large number of files for nothing (between 60 and 240 files in 720p per day)

So I come back to my original idea with the detection of 2 IP addresses. It will be possible to improve the code later and to secure it with a confirmation requested by email for example ...

Kevin Shumaker

unread,
Mar 12, 2021, 6:38:45 AM3/12/21
to Pascal GUILLAUME, motioneye
There is Working Schedule, which would control by time of day.
If you are not at home 8a to 5p Mon - Fri, you could have it on recording during that time, but off the rest of the day, and a different schedule on Sat & Sun.
As to the Location, you would need to find someone willing to write the scripts.

Pascal GUILLAUME

unread,
Mar 12, 2021, 11:28:50 AM3/12/21
to motioneye

My wife is a nurse and has random schedules on weekends and weekdays. I work as a team in 2x8s. I cannot schedule schedules.

If a charitable soul is willing to write me a script, I'm a taker ;-)

secca...@gmail.com

unread,
Mar 13, 2021, 12:00:20 PM3/13/21
to motioneye
I'm in a charitable mood and would like to give back to what nurses provided us over the last year.  The script below should  get you started but I will not be able to assist in follow up questions or debugging.  You will need to do your own investigations and debugging and by doing that you will increase your knowledge regarding scripts, etc.  

#!/bin/bash

function detection_start {
  #Fill in the xxx with the camera id numbers (usually starts at zero)
  #First camera
  
  #Second camera
  
  #etc.  Copy block of code above as needed to start other cameras.
  
  echo "Started Camera(s)"  
}

function detection_stop {
  #Fill in the xxx with the camera id numbers (usually starts at zero)
  #First camera
  
  #Second camera
  
  #Copy blocks of code above to specify more cameras to pause  

  echo "Paused Camera(s)"  
}

# Section below looks for specific IPs on the local network and 
# if they are found, the motion detection is paused.  If the IPs
# are not found, then motion detection is started.  
# How it does it:  
# The ping command (and all other commands executed) have return codes.
# For the ping it is either a one (it failed to find the IP) or 
# a zero (it found the IP).  Within bash scripts the return code of the 
# last command is stored within the variable $?  So after running the
# ping to look for the IP, we then check that return code to determine
# if the ip was found or not.  
#
# This script is NOT efficient in any way.  There are better ways to look
# for local IPs but this should work with minimal additional packages

  #Look for IP of Spouse's Phone
  ping -c 1 192.168.0.10 >null
  if [ $? -eq 0 ]; then
    detection_stop
    exit
  fi

  #Look for IP of my Phone
  ping -c 1 192.168.0.13 >null
  if [ $? -eq 0 ]; then
    detection_stop
    exit
  fi

  #Copy the blocks of code above for each persons phone IP address.

  # In this last line below, we have now looked for all the IPs above
  # and we did not find any of them on the network so the house must be
  # empty and we need to start the detection on the cameras

  detection_start


exit 

#Usage Notes:
#  Install curl via sudo apt-get install curl
#
# SSH into the computer and save this script somewhere as a text file.  
# For example
# /home/myname/scripts/ipchecks.sh
# Mark file as executable via 
# chmod +x /home/myname/scripts/ipchecks.sh
#
# Set it up to run using crontab

sudo crontab -e

# (select nano by default if prompted)
# at bottom enter following lines

# m h dom mon dow command
0  * * * *   /home/myname/scripts/ipchecks.sh
10 * * * *   /home/myname/scripts/ipchecks.sh
20 * * * *   /home/myname/scripts/ipchecks.sh
30 * * * *   /home/myname/scripts/ipchecks.sh
40 * * * *   /home/myname/scripts/ipchecks.sh
50 * * * *   /home/myname/scripts/ipchecks.sh

# this will execute the script every 10 minutes.  Adjust the times  
# as desired. 
# control-x to Save and exit.
# reboot and test.  
# the following are sample commands to try to test the scripts 
# and whether the camera id (xxx) is specified correctly

/home/myname/scripts/ipchecks.sh
     


Kevin Shumaker

unread,
Mar 13, 2021, 12:33:36 PM3/13/21
to secca...@gmail.com, motioneye
Thank you. Looks interesting.
--
You received this message because you are subscribed to the Google Groups "motioneye" group.
To unsubscribe from this group and stop receiving emails from it, send an email to motioneye+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/motioneye/0f924fdd-80a2-46f0-ba15-ff929b1fa216n%40googlegroups.com.

Pascal GUILLAUME

unread,
Mar 14, 2021, 6:47:23 AM3/14/21
to motioneye
I shouldn't have mentioned my nurse wife sorry lol. It's just that we have complex schedules and that we cannot set up working schedules.

Thanks for the script, I'll try to figure something out.

To unsubscribe from this group and stop receiving emails from it, send an email to motioneye+...@googlegroups.com.

W Crater

unread,
Mar 20, 2021, 12:14:45 PM3/20/21
to motioneye
Try this, you just have to do extra steps so you can check check if your phone is in your LAN every x- minutes

Reply all
Reply to author
Forward
0 new messages