Repository navigation
Conversation
get_event_states() and set_event_enabled() went through request(), which turns the document into a dict and back: a write could change the regions and lines of a detection. They also took any error as "not there", a rejected password included, so a caller kept sending it for every detection; and a 403 notSupport, what cameras answer for the detections they lack, read as an authentication error. - ISAPIClient.get_detection_enabled(detection, channel=1) and set_detection_enabled(detection, enabled, channel=1) read and write only the enabled flag below the document's root, as text: the rest is sent back as read, and nothing is sent when it is already so. - A detection the device does not have raises ISAPINotSupportedError (404, 501, notSupport, invalidOperation, also with a 403). 401 and any other 403 raise ISAPIAuthError. - DETECTIONS lists the eight of a video channel; videoLoss is added to EVENT_ENDPOINTS. - get_event_states() and set_event_enabled() use them. get_event_states() stops on rejected credentials; set_event_enabled() raises when the device refuses the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The output, input and holiday methods went through request(): any 403, including the notSupport or invalidOperation of a device without them, was an authentication error; get_output_state() and get_holiday_mode_enabled() took any error, a rejected password included, as False; and set_holiday_mode_enabled() sent the holiday list back rebuilt from a dict. - get_output_active() / set_output_active(): an output's state, and its trigger, with the device's answer as an ImageWriteResult. - get_input_enabled() / set_input_enabled(): whether an alarm input raises alarms. - get_input_active(): whether an input's signal is on now. - get_io_status(): every input and output state in one request (/ISAPI/System/IO/status). - get_holidays() / set_holiday_enabled(id, enabled): each holiday, with its name, mode and dates. A holiday is a set of dates the schedules treat as holidays: there is no device-wide holiday mode. It is written through /ISAPI/System/Holidays/<id>, or within the list on a device without it. - proxy=True on the port lists and the status: the ports of the cameras on an NVR's digital channels (/ISAPI/ContentMgmt/IOProxy), with IDs of channel x 100 + port, used as is with the other methods. - InputPort.enabled: whether the input raises alarms, from the list. - An input and a holiday are written as the detections are: only the enabled flag changes, the rest is sent back as read, nothing is sent when it is already so. - A device without them raises ISAPINotSupportedError, also for a 403 notSupport or invalidOperation; get_output_ports() and get_input_ports() return no ports then. 401 and other 403s raise ISAPIAuthError. - The existing methods use them. get_output_state() and get_holiday_mode_enabled() (any holiday) still return False when they cannot read, but raise on rejected credentials; the setters raise ISAPIError when the device refuses. The reads of a document, its flags and their writes are now shared with the detections (_get_supported_xml, _read_flag, _write_flag). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
baylanger
force-pushed
the
io-holiday
branch
from
November 24, 2026 04:47
ad24caf to
08c44fc
Compare
Contributor
Author
|
@ptarjan whenever you have time, this should now have everything for NVR but if you flag anything let me know. |
Contributor
|
Thanks @baylanger — read through it at 08c44fc. The write path is a big improvement: only the
|
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.
Depends on #162
The output, input and holiday methods went through
request():notSupportorinvalidOperationof a device without them.get_output_state()andget_holiday_mode_enabled()took any error asFalse, a rejected password included. A caller polling them kept sending it.set_holiday_mode_enabled()sent the holiday list back rebuilt from a dict.This adds:
get_output_active(id)/set_output_active(id, active): an output's state, and its trigger. The device's answer comes back as anImageWriteResult. An output set to pulse on the device goes back by itself.get_input_enabled(id)/set_input_enabled(id, enabled): whether an alarm input raises alarms.InputPort.enabledgives it from the list too.get_input_active(id): whether an input's signal is on now.get_io_status(): every input and output state in one request (/ISAPI/System/IO/status), asIOPortStates.get_holidays()/set_holiday_enabled(id, enabled): each holiday, as aHolidaywith its name, mode (date, week or month) and dates. A holiday is a set of dates the schedules treat as holidays: there is no device-wide holiday mode. It is written through/ISAPI/System/Holidays/<id>, or within the list on a device without that endpoint.proxy=Trueonget_output_ports(),get_input_ports()andget_io_status(): the ports of the cameras on an NVR's digital channels (/ISAPI/ContentMgmt/IOProxy). Their IDs are channel × 100 + port (201 is port 1 of channel 2) and work as is with the other methods. The proxy's descriptors hold the camera's password: they are not returned.enabledchanges, the rest is sent back as read, and nothing is sent when it is already so.name, oroutputName/inputName). They return no ports for a device without them.ISAPINotSupportedError(404, 501,notSupport,invalidOperation, also with a 403). 401 and other 403s raiseISAPIAuthError.get_output_state(),set_output_state(),get_holiday_mode_enabled()andset_holiday_mode_enabled()use them:Falsewhen they cannot read, but raise on rejected credentials;get_holiday_mode_enabled()is any holiday enabled;set_holiday_mode_enabled()sets the first holiday;ISAPIErrorwhen the device refuses.The reads of a document and its flags, and their writes, are shared with the detections (
_get_supported_xml,_read_flag,_write_flag).Tests: port lists (names, none, 401, other errors, a port without an ID), proxy ports and status (enabled from the list, proxy IDs, none, status list, not supported, 401, input signal), outputs (state, trigger, refused, 401, not supported, ID as one path segment, legacy methods), inputs (keeps the rest, unchanged sends nothing, not supported), holidays (list, own endpoint, within the list, unchanged sends nothing, unknown ID, a holiday without its flag, none, 401, legacy methods). README updated.
Per this comment - everything in the section "Things we could add but I'd leave out for now" were left out, but if anything is needed in this release we can add.
Not tried on a device: the documents follow the ISAPI layouts of Hikvision's NVR developer guide.
Claude AI tool was used to help write this change.