Difference between revisions of "SMS Notifications"
(→Tips) |
|||
Line 31: | Line 31: | ||
</pre> | </pre> | ||
* When testing use | * When testing use a background filter, and watch the logs. Filters run every 60 seconds by default. | ||
* If you send email as someone other than root, make sure he is in /etc/ssmtp/revaliases | * If you send email as someone other than root, make sure he is in /etc/ssmtp/revaliases | ||
Line 44: | Line 44: | ||
* make sure email is checked off in filters. It gets unchecked easily. | * make sure email is checked off in filters. It gets unchecked easily. | ||
* service zoneminder restart in between changes | * service zoneminder restart in between changes in options - email. | ||
* test setting off alarms by clicking 'force alarm' in the monitor view | * test setting off alarms by clicking 'force alarm' in the monitor view, then unclick to remove alarm. | ||
* make one dedicated email alert account | * make one dedicated email alert account if you want multiple users to receive alerts. | ||
* It's tough to use Motion detection for alerts with IR active.. You might be best off using a device with ZMTrigger, or the cameras built in motion detection if night IR is used.. | * It's tough to use Motion detection for alerts with IR active.. You might be best off using a device with ZMTrigger, or the cameras built in motion detection if night IR is used... False alerts appear when a camera switches from Day lens to IR. | ||
=== Example Filter === | === Example Filter === |
Revision as of 19:21, 3 April 2017
You setup email to point to a text gateway. Setup a filter that monitors the cameras for alarms, and when an alarm is set off you have it send an email to the text gateway (or email address). Simple.
You can get images from the alarm embedded in the text (covered in install steps).
The following is relevant for 1.30
Installation
Follow How to get ssmtp working with Zoneminder.
There are two ways to send emails in options - email. One is sending a short email, and one is designed for longer messages. In the code (as of 1.30 lines 818 and 918), in zmfilter.pl these are sub SendEmail and sub SendMessage. They are distinct functions. SSMTP support is in SendEmail. SSMTP support is not in SendMessage.
Testing the email
First, run a filter in the background (see tips below). Do not try to submit / execute. Second, set debug logging on zmfilter to 9 in options logging. Then watch the debug log as you run the filters. Remember that only SendEmail works with ssmtp, not SendMessage.
Tips
When testing be aware of the following:
- Free email services limit how many emails you are allowed to send through SMTP. It helps to disable cron emails.
- Always test by emailing 1 (or similar low number) results.
- When you make the filter you want the 'current' alarms. You don't want old events.
This is accomplished with a Date/Time greater than or equal to -1 minute.
- If when testing the filter execute, the 'execute' button becomes unclickable, uncheck then recheck the email option.
#watch "tail -n 30000 /var/log/syslog | grep sSMTP | tail"
- When testing use a background filter, and watch the logs. Filters run every 60 seconds by default.
- If you send email as someone other than root, make sure he is in /etc/ssmtp/revaliases
- test emails with
cat file | mail -s "subject" destination@email.com OR echo "some text" | mail -s "subject destination@email.com
- make sure email is checked off in filters. It gets unchecked easily.
- service zoneminder restart in between changes in options - email.
- test setting off alarms by clicking 'force alarm' in the monitor view, then unclick to remove alarm.
- make one dedicated email alert account if you want multiple users to receive alerts.
- It's tough to use Motion detection for alerts with IR active.. You might be best off using a device with ZMTrigger, or the cameras built in motion detection if night IR is used... False alerts appear when a camera switches from Day lens to IR.
Example Filter
For monitoring on the weekend you might have
date/time greater than or equal to -1 minute AND alarm frames greather than or equal to 1 AND Weekday equal to Saturday OR Weekday equal to Sunday AND alarm frames greater than or equal to 1 AND date/time greater than or equal to -1 minute
Notice that you must include all parameters for each group/set individually when there is an OR.
Notes
Notifications are easy if you want alarms emailed between a static time, for example between 12AM and 6AM. If you have a situation where you may not want the alarms to send you text messages on occasion, this requires work.
A feature in the works would allow you to set filters based on run states, which would mean, you could change the run state at any desired time (using Cron), and only then would SMS be sent. Until then, you must have duplicate monitors and have the filters activated on only one of them. If you like, you can compile zoneminder from a package source such as the debian package and add the commits manually at your own risk (it is not difficult, but beware updating).