1

I've seen quite a few security camera examples and many have options for a duty schedule that activates the camera during certain specified days/hours to set up a routine. However I have fairly dynamic schedule and would like for my security cameras to turn on when our phones are not on the WiFi network. This would be an easy shortcut to "on when we're not home" and prevents it from taking intrusive pictures when we are.

Is there a way to configure OpenCV or Motion, or to run a python script to activate a camera when our phones are off the WiFi network? I would like to take advantage of some features of the above software to email or stream footage, so I would like to avoid redesigning a system from the ground up to do this.

Any advice? Thanks!

4
  • At least iPhone disconnects from wifi when home screen is locked to conserve battery. I guess android does the same.
    – Peter
    Nov 16, 2017 at 16:07
  • You can set it to stay connected when locked
    – user974887
    Nov 16, 2017 at 16:20
  • You could - but there's no guarantee that your phone will always connect to the wifi when you're home (e.g. standby modes/flat battery). Or that you will always take your phone with you when you go out (it does happen that sometimes forget to pick it up).
    – Charemer
    Jan 5, 2018 at 16:19
  • Do/will your phones have fixed IP addresses when on your WiFi network? Mar 18, 2019 at 8:25

2 Answers 2

1

You'd need to know either the MAC or IP address of the phones you want to monitor but you could just ping or arping each one in turn and if none reply start your recording otherwise stop recording. Calling something like this from cron might do the trick:

#!/bin/bash
#
# Determine if we should be recording or not by pinging each phone in the list
# and setting the variable to "NO" if any reply. If the variable is still "YES"
# at the end we check if the recording process is running and start it if not.
#


LIST="192.168.123.25 192.168.123.56 192.168.123.13 MyPhone.local 192.168.123.78"


RECORD_CMD="RecordingCommand"


RECORD="YES"    
for HOST in $LIST; do
    ping -c1 "$HOST" &> /dev/null && RECORD="NO"
done

if [ "$RECORD" == "YES" ]; then
    # Start or continue recording?
    if [ $(pgrep -c "$RECORD_CMD") -eq 0 ]; then
        # Not currently recording so we need to start...
        "$RECORD_CMD"
    fi
else
    # Stop recording...
    killall "$RECORD_CMD"
fi


exit 0
0

Your question appears to be about activating and disabling the cameras when you are not able to connect to them directly when your phones are not on the same local subnet. So it seems to be about networking and access to control them, rather than the phones themselves that you reference. That's what I believe that I see here.

Since the cameras are on an RFC 1918 non-routable address, when you're away from home you can't connect to 192.168.1.1 for example as it's not routable across the Internet. The solution is a VPN. Many routers now have this functionality as standard and make it easy to set up a VPN connection back to your home network just by adding a username and password for the VPN account and off you go. Once you connect to your home router via that VPN connection, you can now be connect to the cameras, switch, etc on their non-public IP addresses.

With a VPN you'd just ssh into the Pi-Cam via it's local address and execute sudo systemctl stop/start motion and directly issue commands to control it. Further, with a VPN connection back to your home network, you will be able to view streams from the cameras directly on a web browser on your phone.

1
  • 1
    The question is about disabling the recording while people are at home, and do this by detecting their personal cell phones connected to the home network. If the OP manages to do this, connecting via VPN will likely cause the turning off of the cameras, which is something he/she doesn't want, while he/she isn't home.
    – Mike
    Mar 18, 2019 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.