Is there a way to make motion detect only activate when a certain mac address is not detected on the network?
-
- Posts: 9
- Joined: Tue Dec 29, 2015 5:48 pm
Is there a way to make motion detect only activate when a certain mac address is not detected on the network?
Basically, I only want modect to be active when neither my phone nor my wife's phone is connected to our local network. Is this possible?
Re: Is there a way to make motion detect only activate when a certain mac address is not detected on the network?
Hi,
Well, I read something similar, but used bluetooth to check the status.
viewtopic.php?t=13235
More info here: http://edwardkeeble.com/2014/02/passive-wifi-tracking/
I believe it could be adapted to get the wifi mac address instead of the bt mac address. Good luck. Post results!
PacoLM
Well, I read something similar, but used bluetooth to check the status.
viewtopic.php?t=13235
More info here: http://edwardkeeble.com/2014/02/passive-wifi-tracking/
I believe it could be adapted to get the wifi mac address instead of the bt mac address. Good luck. Post results!
PacoLM
After more than 15 years, no longer using ZM as surveillance system.
Now in the dark side, using a commercial system...
- knight-of-ni
- Posts: 2406
- Joined: Thu Oct 18, 2007 1:55 pm
- Location: Shiloh, IL
Re: Is there a way to make motion detect only activate when a certain mac address is not detected on the network?
Create two run states as documented here:
http://zoneminder.readthedocs.org/en/la ... ay-or-week
The fist state has motion enabled for your camera while the second does not.
While you could probably do something ARP related to find a MAC address, it might be simpler to create static DHCP mappings for the devices in question. Then just write a script that pings for the ip's. If a ping is returned, have the script call the second run state. If a ping is not returned, call the first. Naturally, you will want to add some logic to keep the script from calling the same run state over and over again.
You can call the script via cron job, or you could turn it into a service that runs all the time.
http://zoneminder.readthedocs.org/en/la ... ay-or-week
The fist state has motion enabled for your camera while the second does not.
While you could probably do something ARP related to find a MAC address, it might be simpler to create static DHCP mappings for the devices in question. Then just write a script that pings for the ip's. If a ping is returned, have the script call the second run state. If a ping is not returned, call the first. Naturally, you will want to add some logic to keep the script from calling the same run state over and over again.
You can call the script via cron job, or you could turn it into a service that runs all the time.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
All of these can be found at https://zoneminder.blogspot.com/
-
- Posts: 9
- Joined: Tue Dec 29, 2015 5:48 pm
Re: Is there a way to make motion detect only activate when a certain mac address is not detected on the network?
Thanks for the replies, those suggestions sound within my limited expertise. I'll give them a try this weekend. I'll also have to think of some way to not record myself for the first 10 minutes I get home every day... My router running ddwrt could probably be configured to perform some sort of action when I connect, maybe have it ssh in to my box running zone minder and run some commands?
-
- Posts: 9
- Joined: Tue Dec 29, 2015 5:48 pm
Re: Is there a way to make motion detect only activate when a certain mac address is not detected on the network?
Got it working. I made a script on my router running dd-wrt that runs on startup and scans the list of associated clients every 5 seconds. If neither me nor my wife's phone are connected, it sets zoneminder to a state I created called "Away". If either of us are home, it sets it to "Home".
Script here:
I heavily modified a script I found here: http://tinsley.io/2015/03/openhab-prese ... th-dd-wrt/ I didn't really know what I was doing, so it's kind of hacked together. Only trickery besides getting the logic in the script correct was figuring out how to perform an ssh command that executed a root level command without asking for a password. Seems to work. Also, my router had basically no re-writable storage other than 64kb nvram, so I had to plug a flash drive in to it and have it automount. The ssh key had to be stored on it, and so did the startup script and a small log file I created to log when ssh calls are made.
Uses so little cpu on my router that it always reads 0.0% in 'top'.
Script here:
Code: Select all
#!/bin/sh
###############################################################
# Proximity detection
#
# A script designed to run on a router running DD-WRT to detect certain devices connected to the router.
# It runs at startup and runs continually, checking for a specific list of devices (phones/laptop, etc)
# that connect wirelessly to the router.
#
# The searching frequency can be adjusted to be slower/faster depending on your requirements. Searching too fast
# could burden your router. Too slow might not update the status as necessary for the application.
#
# Make changes below
# MAC address of each device to watch. Don't leave blank.
# For security purposes, if your router requires a password, even if someone could clone the MAC of your
# phone, they would still require the password of your network to link to your router.
macdevice1="28:C6:71:01:81:AD" #Yota
macdevice2="30:75:12:A1:6C:99" #Z3C
# macdevice3="00:00:00:00:00:00" #Device 3
# macdevice4="00:00:00:00:00:00" #Device 4
# Occupied and unoccupied delay in seconds to check status
# Adjust for shorter/longer wait times. For instance, when one device is already
# connected, you might want to check less frequently. This could also delay the
# notification of a disconnect.
delay_occupied=5
delay_unoccupied=5
# initial testing loop count - uncomment the counter near the bottom of the script for testing only.
limit=5
sleep
#initialize internal variables
# status of each MAC. 0=disconnected. 1=connected. -1 initially forces isy update first loop
macconnected1=-1
macconnected2=-1
# macconnected3=-1
# macconnected4=-1
connected=-1
# total number of currently conencted devices.
currentconnected=0
counter=1
# Initial testing loop. Will run continually after testing is complete
while [ $counter -lt $limit ]; do
#maclist stored mac listing in router from status screen
maclist=$(wl_atheros assoclist | cut -d" " -f2)
#reset current status. Two variables are used for each device. The past known status and the current
# status. Only a change is reported to the ISY. Otherwise, it would constantly be updating the ISY with
# the current status creating unnecessary traffic for both the router and the ISY
maccurrent1=0;
maccurrent2=0;
# maccurrent3=0;
# maccurrent4=0;
# compare each device that is currently connected to the MAC devices we want to watch.
for mac in $maclist; do
case $mac in
"$macdevice1") maccurrent1=1;;
"$macdevice2") maccurrent2=1;;
# "$macdevice3") maccurrent3=1;;
# "$macdevice4") maccurrent4=1;;
esac
done
# Look for a change in status from the old known to the current status.
# If it changed, update the ISY. Otherwise it leaves it as is.
if [ $macconnected1 -ne $maccurrent1 ]; then
if [ $maccurrent1 -eq 1 -o $maccurrent2 -eq 1 ]; then
macstatus1="Home";
else
if [ $maccurrent1 -eq 0 -a $maccurrent2 -eq 0 ]; then
macstatus1="Away";
fi
fi
ssh andrew@192.168.1.143 -y -i /tmp/mnt/sda1/dropbear/id_rsa sudo /usr/local/bin/zmpkg.pl $macstatus1 >> /tmp/mnt/sda1/mylogfile 2>&1
fi
if [ $macconnected2 -ne $maccurrent2 ]; then
if [ $maccurrent1 -eq 1 -o $maccurrent2 -eq 1 ]; then
macstatus2="Home";
else
if [ $maccurrent1 -eq 0 -a $maccurrent2 -eq 0 ]; then
macstatus2="Away";
fi
fi
ssh andrew@192.168.1.143 -y -i /tmp/mnt/sda1/dropbear/id_rsa sudo /usr/local/bin/zmpkg.pl $macstatus2 >> /tmp/mnt/sda1/mylogfile 2>&1
fi
# Update the known status from the current. Ready for the next loop.
macconnected1=$maccurrent1;
macconnected2=$maccurrent2;
# macconnected3=$maccurrent3;
# macconnected4=$maccurrent4;
# Total up the number of devices connected.
let currentconnected=$macconnected1+$macconnected2 #+$macconnected3+$macconnected4
connected=$currentconnected
# Delay (sleep) depending on the connection status.
# No devices connected could delay less. Once a device is connected, it could delay longer.
if [ $connected -gt 0 ]; then
sleep $delay_occupied
else
sleep $delay_occupied
fi
#for testing only - uncomment to have the looping stop at X loops defined in variable: limit.
#let counter=$counter+1
done
Uses so little cpu on my router that it always reads 0.0% in 'top'.