iobroker-community-adapters / ioBroker.hikvision-alarmserver

ioBroker adapter to receive alarms/events send from Hikvision cameras.
MIT License
9 stars 4 forks source link
alarm alert camera event hikvision security

Logo

ioBroker.hikvision-alarmserver

NPM version Downloads Number of Installations Current version in stable repository

NPM

Tests: Test and Release

Hikvision Alarm Server adapter for ioBroker

An adapter to receive alarms/events sent from Hikvision cameras.

Tested with Hikvision models:

Success/failure/bug reports welcomed if you have a model not in this list.

Usage

The adapter instance creates a boolean state for each combination of camera/event type reported. Cameras are identified by MAC address (limited by information given by camera).

It appears that cameras repeatedly issue events every second when those events are still valid but no message is sent to clear them. For this reason the adapter automatically clears events that have not been re-reported for more than 5 seconds.

Configuration

ioBroker

Network

In the adapter configuration, select a free port for the adapter to listen on (8089 by default).

Alarm timeout

Most devices signal an alarm is active by constantly sending alert messages. These devices never send an inactive message. Therefore the adapter assumes an alarm is cleared when no message is received after a given period of time. Specify that period here (default 5000ms).

Channel tree

Some cameras (eg. with multiple sensors) report on multiple channels (not to be confused with ioBroker channels). In order to differentiate events between each of the camera's channels check the appropriate option.

For specific event types (eg. field detection, line crossing, etc), some cameras are able to identify motion detection targets (eg. human, vehicle, etc). To create a state for each of these targets under each applicable event type, check the appropriate option.

sendTo

Some event types received have a simple boolean on/off (duration, VMD, etc). For these simple events, setting the appropriate state in ioBroker's object tree is sufficient.

However, some events received include binary data such as images which would be impractical to constantly store in the ioBroker object tree. A more graceful mechanism to handle such events it to use ioBroker's inbuilt messaging system which allows message objects to be communicated between adapters.

While this function is designed mainly for images, sending triggered by simple XML parts is also supported.

The exact message sent is configurable in the Send to message... fields. These fields are evaluated with the JavaScript Function object and have two variables available: ctx (the event context object - see below) and in the case of image parts the raw buffer is available in imageBuffer.

Example 1: Send textual alert on every event received via Telegram

If the Telegram adapter has been implemented, one could set the following parameters in the XML event parts section:

Example 2: Send images via Telegram

If the Telegram adapter has been implemented, one could set the following parameters in the Image event parts section:

Example 3: Send images to custom Javascript

A more complex example is to send each image buffer received to a custom script running inside a Javascript adapter:

Inside the Javascript adapter (instance zero) create a script named myImageHandler and add this code:

onMessage('myImageReceiver', (data, cb) => {
  // data.device holds mac address of device (colons stripped).
  // data.image holds raw image buffer.
  ...
  cb();
});
Event context object

The ctx event context has the following properties:

Saving event data

If checked event XML and/or image data is store on the local filesystem under iobroker-data/hikvision-alarmserver.<instance>.

Warning! these files are not currently purged or archived so use with caution or implement an external strategy for this.

On Camera

Visit the configuration page of your camera(s) and define ioBroker IP/host and port settings:

Alarm Server Options

Make sure to linkage in the events you would like to report to ioBroker includes 'Notify Surveillance Center'. Eg:

Motion Detection Options

Changelog

WORK IN PROGRESS

0.1.0 (2023-01-24)

0.0.7 (2022-12-29)

0.0.6 (2022-12-13)

0.0.5 (2022-12-10)

0.0.2

License

MIT License

Copyright (c) 2022-2024 Robin Rainton robin@rainton.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.