pyHik: etchannel_num = int(etchannel.text) - TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

Hi,

I’m using pyHik through Home Assistant. Everything was working fine for the last 2 years, but suddenly I started receiving the error message below. I recently upgraded my NVR firmware to V4.75.200, and I’m not sure if this is what caused the issue.

NVR: Hikvision DS-7604NI-K1/4P© V4.75.200 build 231110

Error while setting up hikvision platform for binary_sensor

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/hikvision/binary_sensor.py", line 110, in setup_platform
    data = HikvisionData(hass, url, port, name, username, password)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/hikvision/binary_sensor.py", line 157, in __init__
    self.camdata = HikCamera(self._url, self._port, self._username, self._password)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyhik/hikvision.py", line 116, in __init__
    self.initialize()
  File "/usr/local/lib/python3.11/site-packages/pyhik/hikvision.py", line 291, in initialize
    events_available = self.get_event_triggers()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyhik/hikvision.py", line 435, in get_event_triggers
    etchannel_num = int(etchannel.text)
                    ^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

HA config: binary_sensor:

  • platform: hikvision host: 192.168.0.10 port: 80 ssl: false username: user password: pass

About this issue

  • Original URL
  • State: open
  • Created 6 months ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

I think i’ve found the problem and put together a fix in a new branch (https://github.com/mezz64/pyHik/tree/trig-fixes) for you to test. Please replace the hikvision.py file in your local install with the one from that branch and give home assistant a restart to test. If all works well i’ll put together the necessary PR’s to update the library and get things fixed in the main branch.