Commit Graph
25 Commits
Author SHA1 Message Date
Isaac ConnorandClaude Opus 5 e2a325295e Correct Amcrest_HTTP against a live IP5M-1190EW
Verified every added endpoint against an Amcrest IP5M-1190EW running
2.810.00AC004.0.R.  A full get_config() returns 52 sections in ~24s and
the set_config() key form round-trips, but several guesses were wrong:

networkInterface.cgi does not exist, netApp.cgi?action=getInterfaces is
the real endpoint.

userManager.cgi reports a real per-user Id starting at 1, so get_users
was handing callers the array position instead of the number the camera
actually recognises.

modifyUser rejects a partial record with 400.  update_user now reads the
user back and sends the whole record with the changes merged over it.

getSoftwareVersion and getHardwareVersion both answer with a bare
'version=', so device_info's flat merge lost one of them.  The software
one is a single line with the build appended - '2.810.00AC004.0.R,
build:2023-09-04' - so getVersion splits it and returns the build
separately in list context.

The configManager list is now the set that model actually implements.
UPnP and Login are gone, they answer 400; Lighting_V2, WLan, NAS, Record,
Alarm and the VideoIn* sections are added.

That model has no getCurrentProtocolCaps and no coaxialControlIO, and it
answers OK to Lighting/Lighting_V2 writes and then ignores them, so its
WhiteLight is not drivable over http.  Documented rather than papered
over.  update_firmware stays the one unverified path, deliberately.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzHrvNtF13vyYBAJjktam6
2026-08-16 14:49:27 -04:00
Isaac ConnorandClaude Opus 5 b720597295 Expand Amcrest_HTTP API coverage and fix config round-tripping
set_config prepended the section name to keys that already carried it,
so NTP.Address went out as NTP.NTP.Address.  get_config only strips the
'table.' prefix, which leaves keys in exactly the form setConfig wants,
so drop the extra prefix and let reads and writes round-trip.

uri_encode was called but URI::Encode was never imported, and the plain
call leaves reserved characters alone, which corrupts passwords in a
query string.  Import it and always escape reserved characters.

get_config now reads configManager.cgi sections as well as the handful
of dedicated cgis, retries once on a 401 so the fresh digest nonce gets
used, strips the 'table.' prefix, and tries any unrecognised name as a
configManager section so a template can pull in sections the module
doesn't list.

set_config fell off the end of its loop returning undef on success.
reboot POSTed system_reset=1 to setparam.cgi, a Vivotek endpoint, on a
relative url through the raw user agent.  ZoneMinder::General was used
but never required.

Adds device info, time, users, snapshot/rtsp/profiles/probe, white light
and siren, and the remaining PTZ stops and auto pan, matching the method
names cameratool.pl probes for with ->can().

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LzHrvNtF13vyYBAJjktam6
2026-08-15 21:15:27 -04:00
Isaac Connor 479d3a9b05 Split parsing Path and Control address into their own functions, adding back a hack to handle unescaped passwords on ControlAddress. In Amcrest_HTTP if using ControlAddress fails, fall back to using Path 2026-01-22 11:54:58 -05:00
Isaac Connor 6b30d733c5 Update to use shared code from Control.pm 2026-01-06 14:58:40 -05:00
Isaac Connor b5ee966d90 Add some -> and test for ControlDevice so as not to give a warning 2025-01-05 13:12:40 -05:00
Isaac Connor 7c180887c7 Add missing } 2025-01-04 12:12:57 -05:00
Isaac Connor 27dfdd1b4e Upgrade Amcrest to use parent's code 2024-12-21 14:32:48 -05:00
Isaac Connor c6e71b19dc Update to add new api credentials, get_config, set_config, reboot, ping and parse ip/auth from Monitor->Path 2024-03-21 09:44:03 -04:00
Isaac Connor 1f5d7866f7 Merge @alabamatoys' work to add focus controls 2022-04-06 09:03:27 -04:00
Isaac Connor 9438445d74 Fix PTZ Diagonal cmds. Fixes #3300 2021-06-16 15:56:08 -04:00
Isaac Connor df754f0085 Can't do suspend in sendCmd 2021-04-24 19:22:17 -04:00
Isaac Connor 8d4c2afda8 Can't do suspend in sendCmd 2021-04-24 12:00:38 -04:00
Isaac Connor 36ac473ad2 Add suspend/resume of MotionDetection of ModectDuringPTZ is off. 2021-04-23 14:52:29 -04:00
Isaac Connor 7c70c26fbd Cleanup old Continuous stop. Rename lastMove to LastCmd and implement for Zoom 2021-04-21 14:30:02 -04:00
Isaac Connor c9c4224dd2 Change url used for authentication to magicBox.cgi?action=getDeviceType 2021-04-14 17:19:07 -04:00
Isaac Connor 7489c3850d Store last command for continuous moves so that moveStop can send the correct stop command 2021-04-14 17:19:01 -04:00
Isaac Connor cac7ddd89d Discover that authority also contains port. Remove redundant stuff. 2020-02-18 16:48:08 -05:00
Isaac Connor 9a21ebf696 Remove unneeded test for :80 2020-02-18 15:10:44 -05:00
Isaac Connor 568c42cfa9 Use URI to better handle ControlAddress parsing. 2020-02-18 13:05:45 -05:00
Isaac Connor 9c65a8b293 handle Amcrest cameras giving a 401 Unauthorized on the first attempt to send a command. Just send another. 2020-02-12 12:34:43 -05:00
Isaac Connor cc9add9310 fall back to ControlAddress if first ptz get fails 2020-02-11 17:40:33 -05:00
Isaac Connor 1d24e022bb Add realm detection 2020-01-02 16:45:27 -05:00
Isaac Connor 9d57be4c9e google code style, remove redundant code matching parent. Don't re-instantiate UA. 2020-01-02 16:24:43 -05:00
Isaac Connor d9f7e93df3 Fix typo gegress to degrees. Fixes #2601 2019-05-10 14:27:51 -04:00
Chris b8117f7fc9 Add support for control of Amcrest cameras (#2536)
* Add a control module to support the current Amcrest HTTP API

This patch adds ZoneMinder::Control::Amcrest_HTTP

This module is adapted and improved from one available on the ZoneMinder
forums.[1] It appears that a number of individuals have contributed to
it. This is an attempt to correct some of its interactions with ZM::Control
and friends as well as enhance and extend supported control features
for Amcrest cameras.

This work is based on Amcrest HTTP Protocol API Specifications
Rev. 2.12 2017-03-15

[1]https://forums.zoneminder.com/download/file.php?id=1878

* Fixing zoom methods

* Misc. cleanup of comments, etc.

* Fixing up POD, etc.

* Converting line endings to Unix

* Fixing up preset methods

The current Amcrest HTTP API does not support a Home command per se. So this
method is set up to send the camera to the first preset position. Of course,
this presupposes that the user will setup a preset #1 otherwise the command
will fail on a bad preset error.

If a future version of the API supports a true Home command, we'll adjust
at that point. For now this seems to be a useful workaround.

* Removing duplicate home method

* Adding moveAbs method

I'm putting this in, but absolute camera movement does not seem to be well
supported in the classic skin ATM. Reading
www/skins/classic/include/control_functions.php seems to indicate
a faulty implementation, unless I'm reading it wrong. I see nowhere
where the user is able to specify the absolute location to move to. Rather,
the call is passed back movement in increments of 1 unit. At least with the
Amcrest/Duhua API this would result in the camera moving to the 1* or 0* etc.
position.

moveAbsUp, Down, Left, Right, etc. Doesn't make sense given the definition
of Absolute movement.

* Adding a note about the moveMap method

This method does not appear to be implemented in the classic skin,
but we'll leave it here for future implementation. Caveat: It may
or may not work as-is.

* Fixing up zoomConTele/Wide methods

* Adding a vanilla control type for the Amcrest HTTP API

Please note that this control type matches (mostly) the currently
available control options in Amcrest_HTTP.pm. It does not match
all (or possibly any) of the control options available on a specific
Amcrest camera. The user may need to create their own control type
specific to the camera model they are using.

* Removing misplaced comment

Thanks to connortechnology for pointing this out!
2019-02-22 09:17:28 -05:00