Difference between revisions of "Filters"

From ZoneMinder Wiki
Jump to navigationJump to search
 
(33 intermediate revisions by the same user not shown)
Line 1: Line 1:
Here is documentation and some example filters for use with Zoneminder. If you have a useful filter, please add it here.
Here is some documentation and example filters for use with Zoneminder. If you have a useful filter, please add it here.


Review the official documentation here: https://zoneminder.readthedocs.io/en/stable/userguide/filterevents.html
Review the official documentation: https://zoneminder.readthedocs.io/en/stable/userguide/filterevents.html


==Note about purgewhenfull and Additional HDDs==
==Note About the PurgeWhenFull Filter and Additional HDDs==
If you add a new HDD for data storage, you will need to adjust or add a new filter to
If you add a new HDD for data storage, you will need to adjust or add a new filter to
delete events from the HDD. See: https://wiki.zoneminder.com/Using_a_dedicated_Hard_Drive
delete events from the HDD. See: https://wiki.zoneminder.com/Using_a_dedicated_Hard_Drive
Line 9: Line 9:
==Examples==
==Examples==


===Receive email alarm on Weekends===
===Receive Email From an Alarm on Weekends===
For monitoring on the weekend you might have:
For monitoring on the weekend you might have:


Line 19: Line 19:
date/time greater than or equal to -1 minute</pre>
date/time greater than or equal to -1 minute</pre>


Choose "email details upon match" in the filter. For more details see [[Email]]
Note that this is an example without brackets. Brackets can make this simpler. See further below
Note that this is an example without brackets. Brackets can make this simpler, and see below
for such an example.
for an example with those.


The parameter end date/time greater than or equal to -1 minute will select events that occurred in the previous minute only.
The parameter end date/time greater than or equal to -1 minute will select events that occurred in the previous minute only.


===Receive email for specific monitor on Sunday===
===Receive Email for a Specific Monitor on Sunday===
<pre>
<pre>
Monitor id equal to ### AND
Monitor id equal to ### AND
Line 34: Line 33:
</pre>
</pre>


===Run filter from the command line===
===Run Filter From the Command Line===
From the forum:
From the forum:
  You can use cron job to run the filter. Don't check the run in  
  You can use cron job to run the filter. Don't check the run in  
Line 40: Line 39:
  the id is].
  the id is].


===Run a filter from the command line (alt.)===
(alt.)
From the forum:


  sudo zmdc.pl status zmfilter .pl --filter_id=2 --daemon to see what zmdc.pl thinks about it.
  sudo zmdc.pl status zmfilter .pl --filter_id=2 --daemon to see what zmdc.pl thinks about it.
Line 48: Line 46:
  ps ax | grep zmfilter should either list it or not.
  ps ax | grep zmfilter should either list it or not.


===Play audio notification upon alert===
Reference: https://forums.zoneminder.com/viewtopic.php?t=32112
 
===Play Audio Notification Upon Alert===
See forum post:
See forum post:
https://forums.zoneminder.com/viewtopic.php?t=32650
https://forums.zoneminder.com/viewtopic.php?t=32650
===ZMES example===
Reference: https://forums.zoneminder.com/viewtopic.php?p=126956
[[File:Zmes email filter.png|800px|||]]
===Example with brackets / parenthesis===
The brackets can be confusing, so here's an example that makes it clear.
This filter should fire off on any alerts that are on weekends.


[[File:Filter with brackets fixed.png|600px|||]]
===Create Single Video of Multiple Events===
https://forums.zoneminder.com/viewtopic.php?p=135958#p135958
 
===Screenshots===
Per request on the forum, here are some more examples that may help those just starting out. Note that 'message all details' requires the 'new email modules' to be enabled and configured (using MSMTP). For more details, see [[Email]].


===Gallery of Examples===
====Delete False Alarms====
Per request on the forum, here are some more examples that may help those just starting out. Note that 'message details' requires the 'new email modules' to be enabled. For more details, see [[Email]].
[[File:Zm filters2.png|300px|||]]


====Email Object Detected by ZMES====
[[File:Zm filters1.png|300px|||]]
[[File:Zm filters1.png|300px|||]]
[[File:Zm filters2.png|300px|||]]
 
Reference: https://forums.zoneminder.com/viewtopic.php?p=126956
 
====Email Object Detected by ZMES on Weekends Only====
[[File:Zm filters3.png|300px|||]]
[[File:Zm filters3.png|300px|||]]
====Example with brackets / parenthesis====
The brackets can be confusing, so here's an example.
This filter should fire off on any alerts that are on weekends.
[[File:Filter with brackets fixed.png|300px|||]]


==Troubleshooting==
==Troubleshooting==
Line 71: Line 79:
Run the filter with 'list matches' after saving it. Errors in the generated SQL will be displayed.  
Run the filter with 'list matches' after saving it. Errors in the generated SQL will be displayed.  
For example, one error might be to set EndStartTime to 'is' Sunday when it must instead be EndStartTime 'is equal to' Sunday.
For example, one error might be to set EndStartTime to 'is' Sunday when it must instead be EndStartTime 'is equal to' Sunday.
===Logging a Filter in Debug===
Check off Debug log. Choose the filters you want to watch divided by a vertical line (e.g. _zmfilter_2|_zmfilter_3). Choose a destination that is e.g. /var/log/zm/zmfilter_debug_+ (otherwise it will go to the home folder by default). Tail the logs in the filesystem. If you have other questions refer to the question marks on options/logging for each entry. After you are done, disable logging.
[[File:Debug Logging Screenshot.png|300px|||]]


===Changes in 1.36: Filter Runs Before Event Completes===
===Changes in 1.36: Filter Runs Before Event Completes===
Line 77: Line 90:


==Related Links==
==Related Links==
https://forums.zoneminder.com/viewtopic.php?f=42&t=29280 - Filter - odd behavior with "and" and "or"
https://forums.zoneminder.com/viewtopic.php?f=42&t=29280 Filter - odd behavior with "and" and "or"


https://zoneminder.readthedocs.io/en/latest/userguide/filterevents.html#relative-items-in-date-strings
https://zoneminder.readthedocs.io/en/latest/userguide/filterevents.html#relative-items-in-date-strings


https://forums.zoneminder.com/viewtopic.php?f=40&t=28961 - Filter issue - Less than X time doesn't seem to work
https://forums.zoneminder.com/viewtopic.php?f=40&t=28961 Filter issue - Less than X time doesn't seem to work




[[Category:Dummies_Guide]]
[[Category:Dummies_Guide]]

Latest revision as of 14:43, 20 June 2025

Here is some documentation and example filters for use with Zoneminder. If you have a useful filter, please add it here.

Review the official documentation: https://zoneminder.readthedocs.io/en/stable/userguide/filterevents.html

Note About the PurgeWhenFull Filter and Additional HDDs

If you add a new HDD for data storage, you will need to adjust or add a new filter to delete events from the HDD. See: https://wiki.zoneminder.com/Using_a_dedicated_Hard_Drive

Examples

Receive Email From an Alarm on Weekends

For monitoring on the weekend you might have:

end date/time greater than or equal to -1 minute AND
alarm frames greater 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

Note that this is an example without brackets. Brackets can make this simpler. See further below for such an example.

The parameter end date/time greater than or equal to -1 minute will select events that occurred in the previous minute only.

Receive Email for a Specific Monitor on Sunday

Monitor id equal to ### AND
Cause not equal to Signal AND
End Date/Time greater than or equal to -1 minute AND
Alarm frames greater than or equal to 10 AND
Weekday equal to Sunday

Run Filter From the Command Line

From the forum:

You can use cron job to run the filter. Don't check the run in 
background box .. then in cron job run zmfilter.pl --filter_id=[whatever 
the id is].

(alt.)

sudo zmdc.pl status zmfilter .pl --filter_id=2 --daemon to see what zmdc.pl thinks about it.
sudo zmdc.pl start zmfilter .pl --filter_id=2 --daemon
Is basically how to web ui tells zmdc.pl to run it, so running that from command line should do the same thing.
ps ax | grep zmfilter should either list it or not.

Reference: https://forums.zoneminder.com/viewtopic.php?t=32112

Play Audio Notification Upon Alert

See forum post: https://forums.zoneminder.com/viewtopic.php?t=32650

Create Single Video of Multiple Events

https://forums.zoneminder.com/viewtopic.php?p=135958#p135958

Screenshots

Per request on the forum, here are some more examples that may help those just starting out. Note that 'message all details' requires the 'new email modules' to be enabled and configured (using MSMTP). For more details, see Email.

Delete False Alarms

Zm filters2.png

Email Object Detected by ZMES

Zm filters1.png

Reference: https://forums.zoneminder.com/viewtopic.php?p=126956

Email Object Detected by ZMES on Weekends Only

Zm filters3.png

Example with brackets / parenthesis

The brackets can be confusing, so here's an example. This filter should fire off on any alerts that are on weekends.

Filter with brackets fixed.png

Troubleshooting

Always Test the Filter with List Matches

Run the filter with 'list matches' after saving it. Errors in the generated SQL will be displayed. For example, one error might be to set EndStartTime to 'is' Sunday when it must instead be EndStartTime 'is equal to' Sunday.

Logging a Filter in Debug

Check off Debug log. Choose the filters you want to watch divided by a vertical line (e.g. _zmfilter_2|_zmfilter_3). Choose a destination that is e.g. /var/log/zm/zmfilter_debug_+ (otherwise it will go to the home folder by default). Tail the logs in the filesystem. If you have other questions refer to the question marks on options/logging for each entry. After you are done, disable logging.

Debug Logging Screenshot.png

Changes in 1.36: Filter Runs Before Event Completes

Past Zoneminder behavior was to run filters, after an event had completed. However in 1.36+, filters now run during an event. If you want the previous behavior, you will need to "Add an EndDateTime IS NOT NULL rule" https://forums.zoneminder.com/viewtopic.php?t=33409

Related Links

https://forums.zoneminder.com/viewtopic.php?f=42&t=29280 Filter - odd behavior with "and" and "or"

https://zoneminder.readthedocs.io/en/latest/userguide/filterevents.html#relative-items-in-date-strings

https://forums.zoneminder.com/viewtopic.php?f=40&t=28961 Filter issue - Less than X time doesn't seem to work