Hikvision event stream sensors

I can confirm that has fixed my issue with detection.

I tested for both ‘inactive to active’ and ‘active to inactive’ events for the motion event. These were passed through to HA as expected.

I have further checked with line crossing and intrusion (field detection) and these seem to be working correctly.

I will try with other cameras and models to see what else comes up.

Sounds good, looks like you found the issue.

I’ve made the needed changes to the library and also updated the HASS component accordingly. Please test with these versions and see if everything works as expected.

pyHik, Version 0.0.6 on PyPi and here:

HASS Binary Sensor Component:
https://github.com/mezz64/home-assistant/blob/6b010317601f1120e1e7283dbb5914a850ed810c/homeassistant/components/binary_sensor/hikvision.py

1 Like

That update is working on both my dev and home HA instances.

Great! @vladm Can you please update to the latest versions and make sure everything is still working correctly for you?

Upgraded last night to 0.0.6, works well.

Btw, instead of installing hikvision.py into components/binary_sensor/ dir, I tried to put in into config_dir/custom_components/, as described here but it didn’t work. Any ideas?

Did you try config_dir/custom_components/binary_sensor/ dir or just the root of custom_components?

In the root of custom_components. I didn’t know it should follow the components structure of the main code. I’ll give it a try next time you have an update :slight_smile:

I was reading documentation that you posted in your pull request, and noticed delay parameter. I think it might be useful to have different delays for the transitions off => on and on => off.
For example, I want to see “on” in HA immediately, however “off” can be delayed to suppress multiple quick trips as you propose in the docs.

That is how it currently works. The delay will only apply to the off state, not the on state.

@mezz64 So far it is working well for me.

While going through the config for multiple cameras, I had an idea about removing the domain and camera id from the sensor under customize. I feel this will make it easier to setup the cameras.

  • example: binary_sensor.front_line_crossing: becomes line_crossing: in the customize section.

It may also bring it in line with what I have seen in other component configs. But I have found in the past the example of existing components is not always the best practice.

You have a valid point. Since each camera only has binary_sensors and has it’s own customize section it doesn’t make sense to require the sensor type or the camera name in the customize because they can’t change.

PR has been updated.

This functionality has been merged into the latest dev build and it slated to be in the 0.35 stable release.

1 Like

Getting the following error repeatedly in my HA log file.

pyhik.hikvision: Problem finding attribute: list index out of range

Can you please post a more complete log file as well as your configuration and camera type?

Mezz64

I realized going back and looking at the configuration that I had a second camera that I had included was not a true hikvision but an LTS camera who rebadges hikvision.

I am including the xml from this camera to see if maybe it can be added.

triggers.xml (4.6 KB)

Based on that XML the issue looks to be a different XML namespace.

The default hikvision namespace is: http://www.hikvision.com/ver20/XMLSchema
And the LTS camera reports: http://www.std-cgi.com/ver20/XMLSchema

Otherwise the response looks the same so it should be compatible with the existing logic that processes the event stream. Since I can fetch the namespace on the initial camera call i’ll look into making it dynamic rather than hard-coded so other rebaged cameras can hopefully be compatible as well.

Will you be available to test? You’ll need to do a local pip install as described earlier in this thread and edit the version requirement in the hass platform file when the time comes.

Sure. I can test it out. Thanks!

This turned out to be an easy addition so I pushed the necessary changes to the library here:

You can either download the new version and do a local pip install or point pip to the repository and do it that way. Update the REQUIREMENTS line in the hikvision.py file under the binary_sensors direcotry in your hass install to point to 0.0.7 to make it use the new library.

Let me know how things work out.

1 Like

Thanks for the quick turnaround. Working the same as my Hikvision camera now.