Hi
I was thinking of using bluemon:
http://www.matthew.ath.cx/projects/bluemon/
as a way to automatically turn on ZM when I am away, so it aint running when I am here, and is when I am not. Bluemon uses bluetooth to detect your presence (so it looks for a particular bluetooth device like your phone for example) and then when it no longer sees your device it carries out a command.
I was wondering if anyone can suggest which command that should be?
Is "sudo zmpkg.pl start" the best command to start ZM and "sudo zmpkg.pl stop" the best way to stop it, or are there better alternatives??
Using bluetooth to turn on ZM
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
So, I finally got round to writing a script to turn ZoneMinder on and off when I am at home or not, based on my phone's bluetooth connection.
I am a very new to Linux and bash, so you might all laugh at this script and the hacky way I do it, if you have any suggestions, please do add ammednments.
Basically, I have a USB Bluetooth dongle and I use hcitool to scan for my phone's MAC address. If my phone is present, the scan returns my phones name and the script turns ZoneMinder off and writes to a log file.
If my phone is not present, because the MAC address returns no answer/name, then the script turns ZoneMinder on and writes to a log file. It also changes the permissions on the video devices when it turns on ZM since there are somtimes problems with permissions on the USB wecams I use.
Here is the script:
I then use cron to run this script every ten minutes.
If people want to suggest improvements, please do say.
Obviously, if you want to use this script, you will need to change the variables MOBILE - so it says your phones make and the variable SCAN for your phone's bluetooth MAC address .
I am a very new to Linux and bash, so you might all laugh at this script and the hacky way I do it, if you have any suggestions, please do add ammednments.
Basically, I have a USB Bluetooth dongle and I use hcitool to scan for my phone's MAC address. If my phone is present, the scan returns my phones name and the script turns ZoneMinder off and writes to a log file.
If my phone is not present, because the MAC address returns no answer/name, then the script turns ZoneMinder on and writes to a log file. It also changes the permissions on the video devices when it turns on ZM since there are somtimes problems with permissions on the USB wecams I use.
Here is the script:
Code: Select all
#!/bin/bash
# Rupert's Bluetooth monitoring progam to turn zoneminder on and off
# v0.1 March 2009
# written with next to no knowledge of bash and loads of googling
MOBILE=""
SCAN=""
# lets assign the name of our mobile phone to a variable
MOBILE="Nokia"
# lets scan for the presence of my mobile by scanning for its bluetooth MAC address and seeing if it's name is returned and assign it to a variable
SCAN=( $(hcitool name 00:1D:FD:72:61:F8) )
# now, lets do the main part of the script, if the name of my phone is returned then the phone is here, so turn off ZM, it the name isn't returned
# then turn ZM on!
if [ "$MOBILE" = "$SCAN" ]; then
sudo zmpkg.pl stop
echo Mobile present at `date "+%m/%d/%y %l:%M:%S %p"` >> /var/log/bluetoothscan.log
else
sudo chmod 777 /dev/video0
sudo chmod 777 /dev/video1
sudo zmpkg.pl start
echo Mobile absent and ZM started at `date "+%m/%d/%y %l:%M:%S %p"` >> /var/log/bluetoothscan.log
fi
If people want to suggest improvements, please do say.
Obviously, if you want to use this script, you will need to change the variables MOBILE - so it says your phones make and the variable SCAN for your phone's bluetooth MAC address .