Script to check for presence of phone
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I'm running Blue Iris on a dedicated PC to monitor/record the cameras around my house.
I use https://github.com/magapp/blueiriscmd/blob/master/blueiris.py along with this script to monitor for the presence of mine and my wife's phones to trigger whether only the exterior cameras (home) or interior and exterior (away) cameras are activated.
loop=1
sleep=60
while [ "$loop" -eq "1" ]
do
echo ""
echo ""
echo ""
echo ""
echo Phone home = 0, Phone away = 1
#nmap -sn 192.168.1.130 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone1=$?
echo OnePlus 5 = $phone1
#nmap -sn 192.168.1.132 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone2=$?
echo Nexus 5 = $phone2
total=$(($phone1 + $phone2))
echo Phones Total command = $total
if [ "$total" -gt "1" ];
then
echo Detected 0 phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Away' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Away;
else
echo Blue Iris profile is Home, setting profile to Away;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Away;
fi
else
echo Detected 1 or more phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Home' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Home;
else
echo Blue Iris profile is Away, setting profile to Home;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Home
fi
fi
echo ""
echo ""
echo ""
echo ""
echo Execution done, sleeping for $sleep seconds
sleep $sleep
done
I've used both nmap and arp-scan to check for IP addresses and MAC addresses respectively, but I've found neither to be fully reliable and will occasionally not locate our phones on the network and activate the interior cameras when we are home. It will usually revert back after a cycle of the script.
What I'm looking for is some help in getting the check to run twice before changing the status of the cameras.
Thank you in advance.
shell-script
add a comment |Â
up vote
0
down vote
favorite
I'm running Blue Iris on a dedicated PC to monitor/record the cameras around my house.
I use https://github.com/magapp/blueiriscmd/blob/master/blueiris.py along with this script to monitor for the presence of mine and my wife's phones to trigger whether only the exterior cameras (home) or interior and exterior (away) cameras are activated.
loop=1
sleep=60
while [ "$loop" -eq "1" ]
do
echo ""
echo ""
echo ""
echo ""
echo Phone home = 0, Phone away = 1
#nmap -sn 192.168.1.130 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone1=$?
echo OnePlus 5 = $phone1
#nmap -sn 192.168.1.132 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone2=$?
echo Nexus 5 = $phone2
total=$(($phone1 + $phone2))
echo Phones Total command = $total
if [ "$total" -gt "1" ];
then
echo Detected 0 phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Away' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Away;
else
echo Blue Iris profile is Home, setting profile to Away;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Away;
fi
else
echo Detected 1 or more phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Home' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Home;
else
echo Blue Iris profile is Away, setting profile to Home;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Home
fi
fi
echo ""
echo ""
echo ""
echo ""
echo Execution done, sleeping for $sleep seconds
sleep $sleep
done
I've used both nmap and arp-scan to check for IP addresses and MAC addresses respectively, but I've found neither to be fully reliable and will occasionally not locate our phones on the network and activate the interior cameras when we are home. It will usually revert back after a cycle of the script.
What I'm looking for is some help in getting the check to run twice before changing the status of the cameras.
Thank you in advance.
shell-script
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm running Blue Iris on a dedicated PC to monitor/record the cameras around my house.
I use https://github.com/magapp/blueiriscmd/blob/master/blueiris.py along with this script to monitor for the presence of mine and my wife's phones to trigger whether only the exterior cameras (home) or interior and exterior (away) cameras are activated.
loop=1
sleep=60
while [ "$loop" -eq "1" ]
do
echo ""
echo ""
echo ""
echo ""
echo Phone home = 0, Phone away = 1
#nmap -sn 192.168.1.130 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone1=$?
echo OnePlus 5 = $phone1
#nmap -sn 192.168.1.132 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone2=$?
echo Nexus 5 = $phone2
total=$(($phone1 + $phone2))
echo Phones Total command = $total
if [ "$total" -gt "1" ];
then
echo Detected 0 phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Away' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Away;
else
echo Blue Iris profile is Home, setting profile to Away;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Away;
fi
else
echo Detected 1 or more phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Home' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Home;
else
echo Blue Iris profile is Away, setting profile to Home;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Home
fi
fi
echo ""
echo ""
echo ""
echo ""
echo Execution done, sleeping for $sleep seconds
sleep $sleep
done
I've used both nmap and arp-scan to check for IP addresses and MAC addresses respectively, but I've found neither to be fully reliable and will occasionally not locate our phones on the network and activate the interior cameras when we are home. It will usually revert back after a cycle of the script.
What I'm looking for is some help in getting the check to run twice before changing the status of the cameras.
Thank you in advance.
shell-script
I'm running Blue Iris on a dedicated PC to monitor/record the cameras around my house.
I use https://github.com/magapp/blueiriscmd/blob/master/blueiris.py along with this script to monitor for the presence of mine and my wife's phones to trigger whether only the exterior cameras (home) or interior and exterior (away) cameras are activated.
loop=1
sleep=60
while [ "$loop" -eq "1" ]
do
echo ""
echo ""
echo ""
echo ""
echo Phone home = 0, Phone away = 1
#nmap -sn 192.168.1.130 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone1=$?
echo OnePlus 5 = $phone1
#nmap -sn 192.168.1.132 | grep -q latency
arp-scan -r 10 192.168.1.0/24 | grep -q "XX:XX:XX:XX:XX:XX"
phone2=$?
echo Nexus 5 = $phone2
total=$(($phone1 + $phone2))
echo Phones Total command = $total
if [ "$total" -gt "1" ];
then
echo Detected 0 phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Away' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Away;
else
echo Blue Iris profile is Home, setting profile to Away;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Away;
fi
else
echo Detected 1 or more phones, Checking status of Blue Iris;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --list-profiles | grep "Profile 'Home' is active"
profile=$?
if [ "$profile" -eq "0" ];
then
echo Blue Iris profile is already Home;
else
echo Blue Iris profile is Away, setting profile to Home;
/usr/sbin/blueiris.py --host 192.168.1.1:29191 --user user --password password --set-profile Home
fi
fi
echo ""
echo ""
echo ""
echo ""
echo Execution done, sleeping for $sleep seconds
sleep $sleep
done
I've used both nmap and arp-scan to check for IP addresses and MAC addresses respectively, but I've found neither to be fully reliable and will occasionally not locate our phones on the network and activate the interior cameras when we are home. It will usually revert back after a cycle of the script.
What I'm looking for is some help in getting the check to run twice before changing the status of the cameras.
Thank you in advance.
shell-script
shell-script
asked Sep 26 '17 at 18:39
moeava
11
11
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394609%2fscript-to-check-for-presence-of-phone%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password