Commit Graph
3834 Commits
Author SHA1 Message Date
nicandClaude Opus 5.5 090c318186 fix: zmupdate.pl no longer prints "Too late to run INIT block" from ConfigData (#8504)
ZoneMinder::Config has loaded ZoneMinder::ConfigData with a run-time
require since 24a75775d (refs #5547). ConfigData set itself up in an
INIT block, and Perl skips INIT blocks of code compiled after the INIT
phase, printing "Too late to run INIT block at .../ConfigData.pm line
72." zmupdate.pl reaches that through syncConfigFlags() at the end of
every upgrade, and through saveConfigToDB() with -f.

The options were still set up, because loadConfigData() calls
initialiseConfig() itself after the require, so only the warning goes.
ConfigData now calls initialiseConfig() at the end of the module, which
runs whether it is loaded with use or require. initialiseConfig() returns
early on a second call, so loadConfigData()'s call does nothing new.

config_lazy_load.t checks that loading ConfigData at run time prints
no INIT warning.

fixes #8503

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 18:34:40 -05:00
Harsh Singh 8df02cd791 fix: a control module posting a form no longer leaves the form fields in the camera base url (#7676) 2026-11-27 21:17:03 -05:00
fec0999425 feat: ONVIF event notes and tags from what the camera detected (#7712)
* feat: name what an ONVIF camera detected in the event note refs #7688

The ONVIF event note was the raw topic plus the value of the first Data
SimpleItem, e.g. "tns1:RuleEngine/MyRuleDetector/PeopleDetect/true".
parse_event_message() dropped every other item, the item names and the
Source Rule, so cameras that name the detection in an item (Tapo
IsPeople=true under a generic TPSmartEvent topic) or in a value (Ajax
ClassTypes="Human Vehicle") produced notes that did not say what was
detected.

parse_event_message() now also returns every Data SimpleItem and the
Source Rule, and ONVIFEventNote() builds the note from them with rules
that hold across vendors rather than a per-camera list:

- strip the namespace prefix of every topic segment (tns1:, tnsajax:)
- drop a leading RuleEngine/, the root of every analytics topic
- leave out items that are empty or inactive, by the same words
  interpret_alarm_value() uses for the alarm state, and per-object ids,
  which would otherwise add a note per object as notes only accumulate
- leave out the value of items that say active, and State/LogicalState
  items that say active
- add the Rule in parentheses when the camera names one

  Reolink  MyRuleDetector/PeopleDetect
  Tapo     TPSmartEventDetector/TPSmartEvent IsPeople (MyTPSmartEventDetectorRule)
  Ajax     ObjectDetection/Object ClassTypes=Human Vehicle (AjaxObjectRule)

The word lists that drive this sit together, so a camera with other
vocabulary is handled by extending them. The inactive words move from
interpret_alarm_value() into that shared list unchanged. A value found
outside the Data SimpleItems (ElementItem, fallback search) still goes in
the note, and a topic that reduces to nothing is used as it is.

Alarm on/off decisions, the value they use, ONVIF_Alarm_Text matching and
the alarms map keys are unchanged; a test pins interpret_alarm_value() to
its previous results. parse_event_message() and interpret_alarm_value()
are now static, as they use no member state, so they can be tested.

Notes change format: filters matching the old text (e.g. Notes LIKE
"tns1:RuleEngine" or "/true") need updating.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: link existing tags to events and stop logging new ones as errors refs #7688

Event::AddPacket_ tagged events from object detections, but when the tag
name was already in Tags it neither linked it to the event nor cached it,
and leaked the Tag that Tag::find returned. Only a tag name created for the
first time was ever linked, so detections of person, car, ... after the
first never reached Events_Tags.

Move the tagging into Event::AddTag, which finds or creates the tag, links
it once per event and caches it. A mutex guards the cache so the analysis
thread can tag the event too. Event_Tag::save uses INSERT IGNORE so a link
another writer made first (zm_detect via pyzm) is not an error, and
Tag::find returns nullptr without logging two errors when the name is not
there yet, which is how callers learn a tag is new.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: tag events with the objects an ONVIF camera reports refs #7688

Add a per-monitor "Tag Events From ONVIF" checkbox (Monitors.ONVIF_Event_Tags,
off by default). When set, events raised by the ONVIF event listener are
tagged with what the camera detected, through the existing Tags and
Events_Tags tables.

ONVIFEventTags() reads the object from wherever the camera puts it, using
the items parse_event_message() already collects for the note: the topic
(Reolink PeopleDetect), an active item name without its "Is" (Tapo
IsPeople) or the classes in an item value (Ajax ClassTypes="Human
Vehicle"). Camera names map to the names object detection uses, so one tag
means one thing: person, vehicle, animal, package, face, and doorbell for
a Visitor press. An alarm that names no object (motion, tamper, line
crossing, an unknown detector) is tagged with its last topic segment, e.g.
MotionAlarm. The names are a table next to the note vocabulary; items are
judged by the same helper the note uses (inactive, per-object id, generic
state).

Each alarm entry keeps its tags beside its note, SetTagSet() returns them
as SetNoteSet() returns notes, including for a pulse that has already
cleared, and Monitor::Analyse() hands them to Event::AddTag().

Schema: zm_update-1.39.55.sql adds the column, zm_create.sql.in matches,
version 1.39.55. Web: checkbox and help text next to ONVIF Event Listener,
unticked default for the save action. Perl: Monitor field list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: map camera object names to AI object classes for ONVIF tags refs #7688

ONVIF event tags were mapped from a word list compiled into zmc, so a
camera using another word for an object needed a code change. Move the
mapping into the database, on the object classes ZM already has.

- Add AI_Object_Classes.Aliases, a comma separated list of what cameras
  call the class, editable in Options, AI Classes.
- Seed aliases on the COCO person class and add a Camera dataset for
  the objects COCO has no class for: vehicle, animal, package, face and
  doorbell. Aliases already set are kept when the migration reruns.
- zmc loads the class names and aliases when the ONVIF listener starts
  on a monitor with ONVIF_Event_Tags set. A class name maps to itself,
  so a camera reporting Car is tagged car, as object detection would.
- Without the classes (an older database) alarms are tagged with their
  topic, as for an alarm that names no object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: address review of the ONVIF event tags refs #7688

- Event::AddTag tries each name once per event, so a tag that can't be
  saved is not looked up and logged on every frame, and cuts names to
  the 64 characters of Tags.Name. It no longer holds tags_mutex_ over
  the database work, and the Events_Tags row goes through dbQueue, so
  the analysis thread waits on at most the tag lookup.
- Tag::save returns the existing Id when another process created the
  same tag first, instead of failing on the unique Name.
- Event_Tag::save ignores only the duplicate key, not other errors.
- An ONVIF message whose first state item is inactive and a later one
  active (Tapo IsVehicle=false, IsPeople=true) raises the alarm.
- The Is prefix of an item name is matched in any case.
- load_tag_names leaves the error to zmDbFetch, which has logged it.
- The help text says to restart the monitor after changing aliases.
- Re-indent two lines in ProcessPullResponse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: restart ONVIF tagging monitors when an AI class changes refs #7688

zmc reads the object class names and aliases when it starts listening
for ONVIF events, so an alias saved in Options, AI Classes did nothing
until the monitor was restarted by hand. Saving or deleting a class now
restarts the zmc of each monitor with ONVIF_Event_Listener and
ONVIF_Event_Tags set, as saving zones does for their monitor.

Add the Aliases label to en_gb so it can be translated like the other
strings, and say in the help text that saving restarts those monitors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: address Copilot review of the ONVIF event tags refs #7688

- Only a later alarm-state item (IsX, State, Alarm, ...) overrides an
  inactive first one. A later ObjectId or Count describes the object,
  so IsInside=false followed by ObjectId=3 stays an alarm-off.
- 1 is true for a flag item such as IsPeople, as it already was for
  State, so IsPeople=1 is tagged person rather than the topic.
- Cut tag names at 64 UTF-8 characters, the size of Tags.Name, without
  splitting a character, using a new Utf8Truncate helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: leave ONVIF detections out of the note when they are tagged refs #7688

With ONVIF_Event_Tags on, the tags already say what the camera
detected, and name the topic when no object is named, so the note
repeated them: "Motion: MyRuleDetector/PeopleDetect, ONVIF" next to a
person tag. Such a monitor's note now just says ONVIF. With tags off
the note still names the detection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: edit AI class aliases as tags refs #7688

A plain text field gave no hint that aliases are a comma list. Edit
them like an event's tags instead, with the same tag styles: each alias
is a removable tag, and Enter, space or comma adds the one typed. They
are still saved as the comma list zmc reads, so nothing else changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: split ONVIF class values on commas and drop the DogCat alias refs #7688

A camera listing its classes as ClassTypes="Human,Vehicle" was tagged
with neither, as values were split on spaces only. Split on commas too.

Drop DogCat from the animal aliases: no camera is known to send it,
Reolink sends DogCatDetect. Say in the seed where the starter aliases
come from, which of them have been seen from a camera, and that more
are added in Options, AI Classes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: give a new AI class the next free index and refuse a taken one refs #7688

A class's index is the number its dataset's model gives it, which a
dataset with no model behind it (Camera) has no use for, yet the form
required one and took any number, so a second class could get 0.

Leave the index empty on a new class to get the next one in its
dataset, and refuse an index another class of the dataset already has,
naming that class.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: number the placeholders of ClassIndexInUse so translations can reorder them refs #7688

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: source the camera class seed from the 1.39.55 migration refs #7688

The migration carried a copy of db/camera_classes.sql, so the starter
aliases lived in two places. Make it a .sql.in that sources the seed
file, as zm_update-1.39.26.sql.in does with triggers.sql, so fresh
installs and upgrades share one copy. Note in the seed that it must
keep working on a 1.39.55 database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Isaac Connor <isaac@zoneminder.com>
2026-11-27 21:11:06 -05:00
c37bdcd472 fix: zmfilter archive, unarchive, copy and disk space actions update only their own column (#7942)
Co-authored-by: Isaac Connor <isaac@zoneminder.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 18:46:16 -05:00
Jash Ambaliya c9b6cf98f6 fix: option patterns and hints agree with the values they offer, so the default filter position shows as selected refs #8410 (#8411) 2026-11-27 08:53:26 -05:00
Harsh Singh 545faef864 fix: zmaudit check interval test counts sleep($audit_interval) so the Perl CI passes (#8441) 2026-11-27 08:49:42 -05:00
2c32cc6307 fix: keep recording when the Events insert fails, and let zmrecover give the event a normal id refs #7999 (#8409)
* fix: record an event under a time-based id when its insert keeps failing refs #7999

* fix: an event whose insert fails while zmc shuts down records under a fallback id too refs #7987

Event::Event stopped retrying the Events insert as soon as zm_terminate was
set, leaving the event with id 0, so its frames and video were written under
event 0. It now takes the same time-based fallback id it uses after three
failed attempts, so the recording is kept and zmrecover.pl can add it.
Monitor::openEvent never sees an id of 0 any more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: zmrecover gives an event recorded under a fallback id a normal id, and zmaudit keeps it refs #7999

When zmc cannot insert an event's row it records the event under a time-based
id far above the auto increment range. Recovering it as-is would leave that id
in the Events table and push auto increment past it.

ZoneMinder::Event::save_with_new_id() inserts the row without an Id, so it gets
the next auto increment id, then moves the event to match: the Medium or
Shallow directory, the Deep .<id> link or Shallow .<id> file, the
<id>-video.* file, the eid and file name in index.m3u8, DefaultVideo, the
recovered name, and any Frames, Stats, Event_Data, Events_Tags,
Snapshots_Events and Events_* summary rows zmc queued under the old id. If the
directory cannot be moved it removes the new row and keeps the old id, so a
later run can try again. zmrecover.pl saves every recovered event through it
when the id is in the fallback range.

zmaudit deleted the files of any event with no row once it was older than
ZM_AUDIT_MIN_AGE, which would throw away exactly the video the fallback id
exists to keep. It now warns and leaves those events for zmrecover.pl, and its
orphaned Frames, Stats and Event_Data cleanups stop below the fallback range.

The zmaudit and zmrecover tests that replace ZoneMinder::Event with a stub get
the two new names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Jash <jashambaliya1@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 08:48:23 -05:00
6b1bc408c8 fix: FoscamCGI and LoftekSentinel moveStop stops both axes after a diagonal move (#7740)
* fix: FoscamCGI and LoftekSentinel diagonal moves start both directions before stopping refs #7717

* fix: FoscamCGI and LoftekSentinel moveStop stops both axes after a diagonal move refs #7739

---------

Co-authored-by: Isaac Connor <isaac@zoneminder.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 22:20:06 -05:00
Jash Ambaliya af74bed212 fix: zmx10 refuses on/off without a unit and treats 05 and 5 as one unit refs #7759 (#7760) 2026-11-26 22:09:26 -05:00
Jash Ambaliya ed8036ceda fix: zmupdate event migration looks up the web group gid by ZM_WEB_GROUP, not the web user name refs #7787 (#7788) 2026-11-26 22:03:19 -05:00
Jash Ambaliya 568e5ae00b fix: zmx10 keeps each monitor last state across a task reload refs #7849 (#7850) 2026-11-26 21:36:56 -05:00
Jash Ambaliya 066ce9f13a fix: bound the http timeout in the remaining control modules and the base Control user agent refs #7857 (#7858) 2026-11-26 21:31:28 -05:00
Jash Ambaliya df16e96936 fix: zmx10 skips deleted monitors when loading tasks refs #7847 (#7848) 2026-11-26 19:16:48 -05:00
Jash Ambaliya 78cddc9d8e fix: set a timeout on the zmtelemetry, zmupdate and remote zmcControl http clients refs #7859 (#7860) 2026-11-26 19:15:39 -05:00
Jash Ambaliya b82f4f3ec6 fix: stop zmupdate when adding the Colours or Deinterlacing column fails refs #7863 (#7864) 2026-11-26 19:01:37 -05:00
Harsh Singh 3b32f96d08 fix: zmtelemetry shows the usage for an unknown option (#8391) 2026-11-26 19:00:45 -05:00
Harsh Singh dfe0db5cf1 fix: zmonvif-probe --version prints the ZoneMinder version (#8389) 2026-11-26 18:53:31 -05:00
Jash Ambaliya c50b1f19d0 fix: zmaudit and zmfilter use the default interval when the option is 0 instead of spinning refs #8368 (#8369) 2026-11-26 18:52:39 -05:00
Jash Ambaliya 6989abebb7 fix: a cookie lifetime under a minute no longer regenerates the session on every request or purges every session refs #8372 (#8373) 2026-11-26 18:52:14 -05:00
Jash Ambaliya 8eeb479980 docs: Perl tools' help lists every option they accept refs #8360 (#8361) 2026-11-26 18:34:58 -05:00
Jash Ambaliya 3be61290f0 fix: trim spaces around zmx10 Activation, AlarmInput and AlarmOutput entries refs #7737 (#7738) 2026-11-26 18:33:51 -05:00
Jash Ambaliya a48b289d2c fix: zmx10 ignores SIGPIPE when a client hangs up before the reply refs #7851 (#7852) 2026-11-26 18:33:27 -05:00
Harsh Singh fb13a99223 fix: zmpkg run state change no longer resets an empty ONVIF alarm text (#8048) 2026-11-26 08:52:25 -05:00
Harsh Singh 2f4d1fc388 fix: keep an IPv6 camera address in one piece in the HikVision control url (#8309) 2026-11-26 08:48:05 -05:00
Harsh Singh e9789588d5 fix: register the retry credentials of an IPv6 camera under the key LWP looks up in the Uniview control (#8343) 2026-11-26 08:33:04 -05:00
Harsh Singh e16765d221 fix: keep the brackets of an IPv6 camera address from the monitor path in the Vivotek ePTZ control url (#8341) 2026-11-26 08:32:52 -05:00
Harsh Singh ca9c97b462 fix: keep the brackets of an IPv6 camera address in the Grandstream control url (#8339) 2026-11-26 08:32:37 -05:00
Harsh Singh ac628b8cb7 fix: keep the brackets of an IPv6 camera address in the FoscamHD control url (#8337) 2026-11-26 08:32:26 -05:00
Harsh Singh 24a871626c fix: keep the brackets of an IPv6 camera address in the Netcat control url (#8311) 2026-11-26 08:32:07 -05:00
Harsh Singh 8818c89121 fix: keep the brackets of an IPv6 camera address in the Reolink HTTP api url (#8307) 2026-11-26 08:31:56 -05:00
Harsh Singh c405c811df fix: keep the brackets of an IPv6 camera address in the Dahua RPC url (#8305) 2026-11-26 08:31:45 -05:00
Harsh Singh e6c4b00120 fix: s3 event keys put one slash between the Url subpath and the event path (#8325) 2026-11-26 08:31:11 -05:00
Harsh Singh 5f617fa1ad fix: Keekoon open reports success (#8317) 2026-11-26 08:06:43 -05:00
Jash Ambaliya ab52622d14 fix: zmupdate says what to check when it cannot connect to the database refs #8269 (#8270) 2026-11-25 22:54:12 -05:00
Jash Ambaliya 938ff65491 feat: filter Execute reports whether the filter ran, and zmfilter logs the match count at Info for one-off runs refs #8218 (#8219) 2026-11-25 20:32:12 -05:00
Jash Ambaliya 153aabe06b fix: zmstats sleeps 60 seconds when ZM_STATS_UPDATE_INTERVAL is 0 or not a positive number instead of looping without a pause refs #7285 (#7286) 2026-11-25 20:28:47 -05:00
Jash Ambaliya b15c4b621b feat: zmtrigger --help and --version print usage and version instead of starting the daemon refs #8271 (#8272) 2026-11-25 18:18:45 -05:00
Jash Ambaliya 9af4ab56f5 docs: zmonvif-probe help lists the options and commands it accepts refs #8267 (#8268) 2026-11-25 18:18:41 -05:00
Jash Ambaliya 464e922f90 fix: the JSON fallback decoder no longer evals code from a string or from outside strings (#7467)
* fix: the JSON fallback decoder no longer evals code from a string or from outside strings refs #7466

* fix: jsonDecode fallback matches JSON number tokens and allows only JSON punctuation outside strings refs #7466
2026-11-25 18:12:21 -05:00
Jash Ambaliya 7fcb9f3dd5 feat: filters can tag the events they match refs #8239 (#8240) 2026-11-25 18:04:02 -05:00
Harsh Singh 571a0372ee fix: Serial_HEX_PelcoD open reports success (#8254) 2026-11-25 17:49:09 -05:00
Jash Ambaliya 7ae5bb1d86 fix: an event with no id has no relative path in the Shallow and Medium schemes refs #7650 (#7651) 2026-11-25 17:13:02 -05:00
Jash Ambaliya a16d322f63 fix: zmcontrol only runs methods the control module defines, not base class or imported functions (#7605)
* fix: zmcontrol only runs methods the control module defines, not base class or imported functions refs #7604

* fix: PTZ control also refuses methods from the classes ZoneMinder::Control inherits refs #7604
2026-11-25 17:12:58 -05:00
Jash Ambaliya edb5be145a feat: zmdc says when it will restart a crashed daemon and how often it has failed refs #8200 (#8201) 2026-11-25 08:39:27 -05:00
Jash Ambaliya 4561178a95 fix: zmcontrol reopens a closed control before running a command instead of failing until restarted refs #7408 (#7409) 2026-11-25 08:37:32 -05:00
Jash Ambaliya f9bd6bb481 fix: refuse newlines in allow-listed filter commands (#7439)
* fix: refuse newlines in allow-listed filter commands refs #7438

* fix: allow-listed commands also refuse process substitution refs #7438
2026-11-25 08:33:08 -05:00
Harsh Singh cc4615a75c fix: zmfilter %FP% links to the matched filter by Id, which the filter view opens (#7944) 2026-11-24 22:31:44 -05:00
Harsh Singh 55474da847 fix: zmfilter upload archives the event's files when the storage path has a space (#7946) 2026-11-24 22:31:24 -05:00
Harsh Singh 31a7d53b4f fix: find mkv and webm event videos when recovering or closing an event (#7978) 2026-11-24 20:44:25 -05:00
Harsh Singh 2e196808af fix: zmaudit reads the event id from <id>-video.<codec>.<container> in deep event directories (#7980) 2026-11-24 20:43:46 -05:00