Hikvision binary sensors not changing

I have a Hikvision DS-7608NI-I2 / 8P running firmware V4.21.008 build 190625. I have it hooked up to Home Assistant like so:

  - platform: hikvision
    host: 10.0.1.128
    username: admin
    password: ***
    customize:
      motion_1:
        delay: 5
        ignored: false

The motion sensor appears in Home Assistant, but it never changes state. I have the camera set up like so:

And security settings are all digest/basic, with that user appearing in the Integration Protocol list with Administrator access.

I have the cameras set up and working in the interface (as a working stream) - so I know network, auth, etc. is all good. I know its detecting motion since it does record when there is movement. It’s just the binary_sensor that isn’t changing.

Has anyone run into this and had any experience getting the binary_sensor working?

Hi,

Did you get an answer for this? I have a DS-7616NI-E2 / 8P and I’d like to get it going with Hassio, but if it’s not good I’ll scrap it and get an NVR that HA likes better.

I’m using V3.4.103 build 181226, and that was the latest FW as of 6 months ago or so, so I’ll look for the new one. You’re using a US version or the Chinese version? The cameras don’t play well between EN and CH versions.

Regards,

Ambi

Nope. I’ve been exploring using Surveillance Station for my Synology as a replacement, or ZoneMinder, but it’s a bit annoying since I haven’t bought a PoE switch.

Did you try “Trigger Alarm Output D1->1”? When I had mine sending emails, I needed to do that.

Regards,

Ambi

Yeah - the screenshot above is from when I had it off, but have generally had it on.

1 Like

I revisted this today and have it working (hopefully long term). All the settings above are right (plus the trigger alarm output D1->1 setting mentioned by @Ambidexter above.

What I had to do was reset the NVR completely (Configuration / System / Maintenance / [Restore]), then go to each camera and reset them the same way. As I reset each camera, it started reporting motion properly.

And at some point in the last day, it’s stopped working and all the sensors are stuck at random statuses.

Frustrating part is that there are no logs on either side to look at :neutral_face:

Ditto for a DS-7608NI-I2-8P on latest and greatest RPi4. I get this in the log viewer:

  File "/usr/local/lib/python3.9/site-packages/pyhik/hikvision.py", line 615, in process_stream
    state = self.fetch_attributes(etype, echid)
  File "/usr/local/lib/python3.9/site-packages/pyhik/hikvision.py", line 663, in fetch_attributes
    if sensor[1] == int(channel):
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Perhaps this is from a change in Python versions?

I have fixed it changing the file /usr/local/lib/python3.10/site-packages/pyhik/hikvision.py
from:

    def fetch_attributes(self, event, channel):
        """Returns attribute list for a given event/channel."""
        try:                       
            for sensor in self.event_states[event]:
                if sensor[1] == int(channel):                
                    return sensor                                       
        except KeyError:                                                 
            return None

to:

    def fetch_attributes(self, event, channel):
        """Returns attribute list for a given event/channel."""
        if channel == None:
            return None
        try:                       
            for sensor in self.event_states[event]:
                if sensor[1] == int(channel):                
                    return sensor                                       
        except KeyError:                                                 
            return None
1 Like