Currently I've got my user cron starting Motion on a timer when I typically leave for work, and then killing it when I typically get home, so I can watch my cat/burglars/etc:
0 9 * * * killall motion ; motion
30 18 * * * killall motion
The config file used is ~/.motion/motion.conf and has daemon on.
But it would be better if it could detect when I'm actually home and disable the webcam during those times, and enable it at other times. I was thinking my presence could be detected by my Android phone joining the LAN. So something like
- A script that checks every few minutes whether my phone's hostname or MAC address is currently on the LAN
- A Tasker script on my phone that contacts the home computer in some way (simple web server?) when it joins a certain SSID
- A combination of the above
- ...
Any better ideas or advice about how to implement one of these? Tasker is easy to use, but costs $6, so a solution that doesn't depend on it would be useful by a wider audience.
My first attempt at the arp-scan solution doesn't work very well. It creates multiple instances of motion and doesn't detect the phone reliably, causing the camera to turn on and off sporadically. So maybe it should be more like "check every minute if the phone is present. only turn the camera on if the phone has not been seen for 15 minutes".
Ok, I wrote a python script to do an arp-scan once per minute, and it detects the phone perfectly:
2012-11-27 18:29:10.551552 No
2012-11-27 18:30:22.295997 No
2012-11-27 18:31:34.077431 No
2012-11-27 18:32:45.804675 No
2012-11-27 18:33:57.545211 No
2012-11-27 18:35:09.261680 No
2012-11-27 18:36:20.974378 Yes
2012-11-27 18:37:21.901076 Yes
2012-11-27 18:38:22.417423 Yes
2012-11-27 18:39:22.836101 Yes
2012-11-27 18:40:23.463507 Yes
2012-11-27 18:41:23.876693 Yes
So there's something wrong with cron or the way I'm starting motion or something.
I tried to run /etc/init.d/motion start instead of running it and killing it as a user, but that method doesn't work:
* Not starting motion daemon, disabled via /etc/default/motion
So I edited /etc/default/motion to say start_motion_daemon=yes and tried again:
~> /etc/init.d/motion start
mkdir: cannot create directory `/var/run/motion': Permission denied
I don't even know what that means.