Motion - On Xxx Commands Patch

OnXxxCommandsPatch

Introduction

Redesign of the current external commands interface. (Ref FeatureRequest2005x03x31x223032)

Description of Patch

A redesign of the external commands was due. They were not very easy to understand, not all were flexible enough and some were missing. See also OnXxxxFeatureDiscussion.

This is how the new script commands look like:

Function Old Option New Option Argument Appended
Start of event (first motion) execute on_event_start None
End of event (no motion for gap seconds) New! on_event_end None
Picture saved (jpg or ppm) onsave on_picture_save Filename of picture
Movie starts (mpeg file opened) onmpeg on_movie_start Filename of movie
Movie ends (mpeg file closed) onffmpegclose on_movie_end Filename of movie
Motion detected (each single frame with Motion detected) New! on_motion_detected None

Mail and sms has been removed because they were not configurable. If you want to send event-based mails or sms, just use one of those commands above and send the mail from that script.

Installation of Patch

Copy the patch into a clean motion-3.2.1_snap10 directory and unzip it.

Apply the patch:

patch -p1 < onxxx-commands.diff
./configure
make

Usage of new features.

The mail and sms options are now removed. But it is still possible to do. The most commonly used feature was the mail feature. The scripts below written by JoergWeber do exactly the same as the "mail" and "sms" options did using the new on_event_start option.

#!/bin/sh

# Motion sample script to send an e-mail at start of an event.
# Replaces the former 'mail' option.
# Just define this script as 'on_event_start'-script in motion.conf like that:
# on_event_start send_mail "%Y-%m-%d %T"

#change to suit your needs:
#location of 'mail' binary
MAIL="/usr/bin/mail"
#Destination e-mail address
TO="root@localhost"
#Subject of the e-mail
SUBJECT="Motion detected"

#Don't change anything below this line
echo -e "This is an automated message generated by motion.\n\nMotion detected: $1\n\n" | $MAIL -s "$SUBJECT" $TO




#!/bin/sh

# Motion sample script to send an sms at start of an event.
# Replaces the former 'sms' option.
# Just define this script as 'on_event_start'-script in motion.conf like that:
# on_event_start send_sms "%Y-%m-%d %T"
#
# If you want to send an e-mail message here as well, just uncomment the last
# line of this script.


#change to suit your needs:
#location of 'sms-client' binary
SMS_CLIENT="/usr/bin/sms_client"
#Destination sms number
TO="12345"


#Don't change anything below this line
$SMS_CLIENT $TO "Motion detected $1"

#/usr/local/bin/send_mail $1





Discussion and Comments


I have added a small sample script to send e-mails. Replaces the former 'mail' option.

-- JoergWeber - 07 Apr 2005

onxxx-commands.diff.gz patch has been implemented in smap11

-- KennethLavrsen - 08 Apr 2005

I have added a small sample script to send sms. Replaces the former 'sms' option.

-- JoergWeber - 08 Apr 2005
I Attachment Action Size Date Who Comment
onxxx-commands.diff.gzgz onxxx-commands.diff.gz manage 3 K 31 Mar 2005 - 21:53 JoergWeber Also contains small despeckle fix
send_mailEXT send_mail manage 561 bytes 07 Apr 2005 - 22:21 JoergWeber sample script to send e-mails
send_smsEXT send_sms manage 568 bytes 08 Apr 2005 - 22:24 JoergWeber sample script to send sms
Topic revision: r9 - 28 May 2005, KennethLavrsen
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.