Repository navigation
Conversation
Unit tests can't tell us how a given camera or NVR behaves; this script
runs the image settings code against real hardware and prints a short
PASS/FAIL report that can be pasted into a bug report.
Read-only by default: lists the channels, every image setting with its
path and current value, and the device type.
Options that change something (only numeric settings) put the original
value back afterwards, will report on an error.
--write change one numeric setting by one step (default
Color/brightnessLevel, or pick one with --path) and
read it back
--conflicts WDR / HLC / BLC / defog conflict matrix
--bad-password tries one login with a wrong password
--all everything above
An NVR or DVR is detected from the device type and its attached cameras
are used through the ImageProxy endpoints (--proxy / --no-proxy override
this, --channel selects the camera).
NVR or DVR still turns the proxy on straight away. For any other type, the script tries the camera image endpoints. If they fail with a plain ISAPIError, such as the 503 and 400, it tries the proxy endpoints. If those list channels, it prints camera image endpoints failed (...); trying the proxy endpoints.
Some recorders (ex. DS-7608NI-EV2/8P V3.4.96) report the type of a camera - or fail the device information request altogether - and answer for the camera image endpoints w/ 503 serviceUnavailable. Auto-detection gave up when the device type could not be read; the read-only run failed even though --proxy passed. fix - Read the device type if possible but do not depend on it: unless it says NVR or DVR, try the camera image endpoints and if they fail with a device error (not a rejected login or a conn err), try the proxy endpoints before giving up.
baylanger
force-pushed
the
tool-live_image_check
branch
from
November 7, 2026 19:07
24d641d to
c6b1967
Compare
mezz64
reviewed
Nov 12, 2026
mezz64
left a comment
Owner
There was a problem hiding this comment.
I'm onboard with adding this, but considering the ISAPI functionality is only a subset of what pyHik can do, I don't know that the path should be simply called "check" as i'd expect that to check the basic event stream functionality. I think this is better suited as "checkiaspi" or something similar so a separate module can be added later to perform the same function on the base event stream monitoring code.
Also, the readme changes need cleaned up now that #151 is merged and I'd prefer you split out the xmldict change into a separate PR.
Otherwise a review flagged a couple small issues:
- An error during the restore step in check_write can hide the original error, and the restore keeps sending requests after an auth error.
- The restore writes back every value that changed, not just the ones in result.also_changed.
- TESTING.md says cd pyhik; it should be cd pyHik.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
python -m pyhik checkA check to run by hand against a real camera or NVR. Unit tests have to run
without hardware. This is for people with a device who want to try the
image settings code or report a problem.
python -m pyhik <command>is a small dispatcher (pyhik/__main__.py) that imports acommand only when it is asked for.
checkis the first command, so others (for exampledump) can be added later.Run
Optional:
CAMERA_PORT(80, or 443 with HTTPS),CAMERA_SSL=1,CAMERA_VERIFY_SSL=0for aself-signed certificate.
--host,--port,--username,--ssland--no-verifydo the same asCAMERA_HOST,CAMERA_PORT,CAMERA_USERNAME,CAMERA_SSL=1andCAMERA_VERIFY_SSL=0, and win overthem. The password is read only from the environment, never from the command line, and never printed.
What it does
python -m pyhik check... --writeColor/brightnessLevelby one step, reads it back, restores it.... --write --path Color/contrastLevel--pathis only used with--write.... --conflicts... --bad-passwordISAPIClientandHikCamera: at least two failed logins.... --all... -vA plain
--writeends by naming a few switch and select paths to try with--path. If a changeswitches another setting off to make room (WDR, BLC, HLC and defog exclude each other), that setting
is put back too and listed.
One channel is checked per run (the first listed unless
--channelisgiven). On an NVR or DVR the attached camera is used through the ImageProxy
endpoints:
The NVR is detected from the device type. That is not enough on its own: some NVRs report
IPC, and the device information may not be readable at all. When the camera image endpoints failand the NVR ones work, the NVR endpoints are used, and it prints which it chose and why.
--proxy/--no-proxyoverride the detection.The device information is asked once per run, whether it answers or not. When it fails, the device
line shows the error with its HTTP status (for example
model=? (ISAPIError: Request failed with status 503)) and the run goes on.Safety
after an error, and prints
NOT RESTORED, set it back by handif itcould not.
lock an account.
--bad-passwordmakes at least two failed logins (one perclient, more if a client retries); do not use it on an account that is close
to being locked.
Tested
Unit tests (
test/test_check.py) cover the NVR detection, the write path (number, switch, select, a conflict, a failed restore), the connection options (host, port, username, HTTPS, certificate check) and thepython -m pyhikdispatch, with fake devices.On real camera DS-2CD2385G1
On a DS-7608NI-EV2/8P NVR (V3.4.96): 8 channels listed, a read, and a write of a switch
(enableImageLossDetection) through ImageProxy with the read back and the restore both
checked.
Dependencies
[ ] Requires #151 (PR4 List image channels and support NVR-attached cameras through ImageProxy) to be merged first.