Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add DS-KV8213-WME1(C): ISAPI error Client error '404 Not Found' for url 'http://192.168.1.25/ISAPI/System/status' #196

Closed
felipecrs opened this issue Aug 5, 2024 · 48 comments

Comments

@felipecrs
Copy link

felipecrs commented Aug 5, 2024

When I fill the doorbell URL, username and password, and press the button, the form just refreshes and the device is not added.

I can see the following in the logs:

ISAPI error Client error '404 Not Found' for url 'http://192.168.1.25/ISAPI/System/status'

I can confirm ISAPI is working though:

curl --fail-with-body --digest "http://admin:topsecret@192.168.1.25/ISAPI/System/IO/inputs"
<?xml version="1.0" encoding="UTF-8"?>
<IOInputPortList version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<IOInputPort version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<id min="1" max="4">1</id>
<name>AI1</name>
<IOUseType>doorStatus</IOUseType>
</IOInputPort>
<IOInputPort version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<id min="1" max="4">2</id>
<name>AI2</name>
<IOUseType>disable</IOUseType>
</IOInputPort>
<IOInputPort version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<id min="1" max="4">3</id>
<name>AI3</name>
<IOUseType>openDoor</IOUseType>
</IOInputPort>
<IOInputPort version="2.0" xmlns="http://www.isapi.org/ver20/XMLSchema">
<id min="1" max="4">4</id>
<name>AI4</name>
<IOUseType>disable</IOUseType>
</IOInputPort>
</IOInputPortList>
@felipecrs
Copy link
Author

@bkarakashev mind sharing your doorbell/camera model?

@felipecrs
Copy link
Author

I think your issue is very different. I'd recommend you open a separate issue.

@mihaimdinca
Copy link

Similar error for DS-KV6113-WPE1(C).
This error originated from a custom integration.

Logger: custom_components.hikvision_next.config_flow
Source: custom_components/hikvision_next/config_flow.py:82
integration: Hikvision NVR / IP Camera (documentation, issues)
First occurred: 21:53:23 (1 occurrences)
Last logged: 21:53:23

ISAPI error Client error '404 Not Found' for url 'http://192.168.1.77/ISAPI/System/status' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404

@mihaimdinca
Copy link

Maybe not working with doorbells (yet?)

@maciej-or
Copy link
Owner

hi there,
could you check this version https://github.com/maciej-or/hikvision_next/tree/fix/doorbell-initialization
if it works with doorbell?
I changed auth checking method request from
/ISAPI/System/status
to
/ISAPI/System/deviceInfo
which should be available.
(Hit green button Code and download zip file)
I have no access to this device.

@felipecrs
Copy link
Author

The following happens:

image

I also found this log:

Registrador: homeassistant.util.loop
Fonte: util/loop.py:136
Ocorreu pela primeira vez: 17:37:41 (1 ocorrências)
Último registro: 17:37:41

Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7fcb7ddc3cd0>,) inside the event loop by custom integration 'hikvision_next' at custom_components/hikvision_next/isapi_client.py, line 43: self.session = httpx.AsyncClient(timeout=self.timeout) (offender: /usr/local/lib/python3.12/site-packages/httpx/_config.py, line 149: context.load_verify_locations(cafile=cafile)), please create a bug report at https://github.com/maciej-or/hikvision_next/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 556, in start task = asyncio.Task(coro, loop=loop, eager_start=True) File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 477, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 559, in _handle return await handler(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, **request.match_info) File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin return await func(self, request, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post return await super().post(request, flow_id) File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper return await method(view, request, data, *args, **kwargs) File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post result = await self._flow_mgr.async_configure(flow_id, data) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 370, in async_configure result = await self._async_configure(flow_id, user_input) File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 417, in _async_configure result = await self._async_handle_step( File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 520, in _async_handle_step result: _FlowResultT = await getattr(flow, method)(user_input) File "/config/custom_components/hikvision_next/config_flow.py", line 66, in async_step_user await isapi.get_device_info() File "/config/custom_components/hikvision_next/isapi.py", line 201, in get_device_info hw_info = (await self.request(GET, "System/deviceInfo")).get("DeviceInfo", {}) File "/config/custom_components/hikvision_next/isapi.py", line 791, in request response = await self.isapi.request(method, full_url, present, **data) File "/config/custom_components/hikvision_next/isapi_client.py", line 69, in request await self._detect_auth_method() File "/config/custom_components/hikvision_next/isapi_client.py", line 43, in _detect_auth_method self.session = httpx.AsyncClient(timeout=self.timeout)

@mihaimdinca
Copy link

It finished the config flow showing a success message but than it showed this Failed setup, will retry: Unknown error connecting to http://192.168.##.##. Cannot initialize hikvision_next. Error is 'str' object has no attribute 'get'

@felipecrs
Copy link
Author

That's correct, config flow finished successfully.

@maciej-or
Copy link
Owner

maciej-or commented Oct 19, 2024

Update the branch and check again.
In case of fail please enable log for the integration and paste responses from the device, that would be helpful.
add in confuguration.yaml before restart

logger:
  logs:
    custom_components.hikvision_next: debug

@mihaimdinca
Copy link

No devices or entities
Failed setup, will retry: Unknown error connecting to http://192.168.1.77. Cannot initialize hikvision_next. Error is 'str' object has no attribute 'get' once more

@mihaimdinca
Copy link

Home Assistant Core
2024-10-21 13:05:57.998 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:05:58.053 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:06:03.221 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:06:13.645 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:06:34.070 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:07:14.616 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:08:35.098 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:08:52.989 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:08:58.233 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:09:08.412 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:09:28.741 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:10:09.179 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:11:29.764 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:12:42.886 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:12:42.941 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:12:48.500 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:12:58.785 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:13:19.030 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:13:59.228 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:15:19.583 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:15:28.190 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:15:33.639 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:15:43.816 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:16:04.344 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo
2024-10-21 13:16:44.599 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.77/ISAPI/System/deviceInfo

@mihaimdinca
Copy link

I added the lines in config.yaml, enabled debug in the integration page, filtered the logs in home Assistant core by http://192.168.1.77/ISAPI/System/deviceInfo

@mihaimdinca
Copy link

I also temporarily stopped an addon that has access to the device. If I need to do something different please let me know.

@mihaimdinca
Copy link

Also, my device is DS-KV6113-WPE1(C) if it matters in any way

@felipecrs
Copy link
Author

This is the output:

<?xml version="1.0" encoding="UTF-8"?>
<DeviceInfo version="2.0"
	xmlns="http://www.isapi.org/ver20/XMLSchema">
	<deviceName>OUTDOOR STATION</deviceName>
	<deviceID>7d49925b-4fc7-406b-a0ec-bc5e3359252f</deviceID>
	<deviceDescription>     Vis</deviceDescription>
	<deviceLocation>STD-CGI</deviceLocation>
	<systemContact>STD-CGI</systemContact>
	<model>DS-KV8213-WME1(C)</model>
	<serialNumber>DS-KV8213-WME1(C)0120230508RRAB0353909</serialNumber>
	<macAddress>bc:5e:33:59:25:2f</macAddress>
	<firmwareVersion>V2.2.77</firmwareVersion>
	<firmwareReleasedDate>build 240515</firmwareReleasedDate>
	<bootVersion>33685581</bootVersion>
	<bootReleasedDate>1574159</bootReleasedDate>
	<hardwareVersion>0x0</hardwareVersion>
	<encoderVersion>V2.9</encoderVersion>
	<encoderReleasedDate>build 240223</encoderReleasedDate>
	<deviceType>VIS</deviceType>
	<subDeviceType>villaDoorStation</subDeviceType>
	<telecontrolID>88</telecontrolID>
	<supportBeep>true</supportBeep>
	<supportVideoLoss>true</supportVideoLoss>
	<alarmOutNum>2</alarmOutNum>
	<alarmInNum>4</alarmInNum>
	<RS485Num>1</RS485Num>
	<customizedInfo></customizedInfo>
</DeviceInfo>

@felipecrs
Copy link
Author

These are the logs I was able to capture:

2024-10-21 10:52:07.908 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.25/ISAPI/System/deviceInfo
2024-10-21 10:52:07.908 DEBUG (MainThread) [custom_components.hikvision_next.isapi]
{'DeviceInfo': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'deviceName': 'OUTDOOR STATION', 'deviceID': '7d49925b-4fc7-406b-a0ec-bc5e3359252f', 'deviceDescription': 'Vis', 'deviceLocation': 'STD-CGI', 'systemContact': 'STD-CGI', 'model': 'DS-KV8213-WME1(C)', 'serialNumber': 'DS-KV8213-WME1(C)0120230508RRAB0353909', 'macAddress': 'bc:5e:33:59:25:2f', 'firmwareVersion': 'V2.2.77', 'firmwareReleasedDate': 'build 240515', 'bootVersion': '33685581', 'bootReleasedDate': '1574159', 'hardwareVersion': '0x0', 'encoderVersion': 'V2.9', 'encoderReleasedDate': 'build 240223', 'deviceType': 'VIS', 'subDeviceType': 'villaDoorStation', 'telecontrolID': '88', 'supportBeep': 'true', 'supportVideoLoss': 'true', 'alarmOutNum': '2', 'alarmInNum': '4', 'RS485Num': '1', 'customizedInfo': None}}
2024-10-21 10:52:07.963 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.25/ISAPI/System/deviceInfo
2024-10-21 10:52:07.963 DEBUG (MainThread) [custom_components.hikvision_next.isapi]
{'DeviceInfo': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'deviceName': 'OUTDOOR STATION', 'deviceID': '7d49925b-4fc7-406b-a0ec-bc5e3359252f', 'deviceDescription': 'Vis', 'deviceLocation': 'STD-CGI', 'systemContact': 'STD-CGI', 'model': 'DS-KV8213-WME1(C)', 'serialNumber': 'DS-KV8213-WME1(C)0120230508RRAB0353909', 'macAddress': 'bc:5e:33:59:25:2f', 'firmwareVersion': 'V2.2.77', 'firmwareReleasedDate': 'build 240515', 'bootVersion': '33685581', 'bootReleasedDate': '1574159', 'hardwareVersion': '0x0', 'encoderVersion': 'V2.9', 'encoderReleasedDate': 'build 240223', 'deviceType': 'VIS', 'subDeviceType': 'villaDoorStation', 'telecontrolID': '88', 'supportBeep': 'true', 'supportVideoLoss': 'true', 'alarmOutNum': '2', 'alarmInNum': '4', 'RS485Num': '1', 'customizedInfo': None}}
2024-10-21 10:52:07.983 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.25/ISAPI/System/capabilities
2024-10-21 10:52:07.984 DEBUG (MainThread) [custom_components.hikvision_next.isapi]
{'DeviceCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'SysCap': {'isSupportDst': 'true', 'NetworkCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'isSupportWireless': 'true', 'isSupportNtp': 'true', 'isSupportFtp': 'true', 'isSupportHttps': 'true', 'SnmpCap': {'isSupport': 'false'}, 'isSupportEZVIZ': 'true', 'isSupportEhome': 'false', 'isSupportWirelessServer': 'true', 'isSupportEZVIZUnbind': 'true', 'isSupportSip': 'true'}, 'IOCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'IOInputPortNums': '4', 'IOOutputPortNums': '2'}, 'SerialCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'rs485PortNums': '0', 'supportRS232Config': 'false', 'rs422PortNums': '0', 'rs232PortNums': '1'}, 'AudioCap': 'true'}, 'SecurityCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'supportUserNums': '32', 'userBondIpNums': '0', 'userBondMacNums': '0', 'isSupCertificate': 'false', 'issupIllegalLoginLock': 'true', 'isSupportOnlineUser': 'true', 'isSupportAnonymous': 'false', 'isSupportStreamEncryption': 'false', 'securityVersion': {'@opt': '1,2', '#text': '1'}, 'keyIterateNum': '100', 'isSupportUserCheck': 'true', 'isSupportSecurityQuestionConfig': 'true', 'SecurityLimits': {'LoginPasswordLenLimit': {'@min': '1', '@max': '16', '#text': '16'}, 'SecurityAnswerLenLimit': {'@min': '1', '@max': '128', '#text': '128'}}, 'RSAKeyLength': {'@opt': '1024,2048', '#text': '2048'}, 'isSupportConfigFileImport': 'true', 'isSupportConfigFileExport': 'true', 'isIrreversible': 'true', 'salt': 'UK8PVU4G609NMG2IL1E5GCFE56JCELH86PEHKYD6ENT1JVZKCD69QLNB76OL759T', 'isSupportSecurityEmail': 'true', 'DoubleVerificationCap': {'isSupportUsersConfig': 'true', 'isSupportUsersPermissionConfig': 'true', 'isSupportFactoryReset': 'true'}, 'isSupportEncryptCertificate': 'true', 'isSupportCertificateCustomID': 'true'}, 'EventCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'isSupportHDFull': 'false', 'isSupportHDError': 'false', 'isSupportNicBroken': 'false', 'isSupportIpConflict': 'false', 'isSupportIllAccess': 'false', 'isSupportViException': 'false', 'isSupportViMismatch': 'false', 'isSupportRecordException': 'false', 'isSupportMotionDetection': 'true', 'isSupportVideoLoss': 'false', 'isSupportTamperDetection': 'false', 'isSupportHumanRecognition': 'true', 'isSupportFaceContrast': 'true'}, 'VideoIntercomCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'isSupportDeviceId': 'true', 'isSupportOperationTime': 'true', 'isSupportRemoteOpenDoor': 'true', 'isSupportKeyCfg': 'true', 'isSupportAlarmUploadCfg': 'true', 'isSupportSendCardCfg': 'true', 'isSupportCardSectorCheck': 'true', 'isSupportDeviceLanguageCfg': 'true', 'isSupportIssueCards': 'true', 'isSupportAlarmControlByPhone': 'false', 'isSupportWorkStatus': 'true', 'isSupportRingBackTone': 'true', 'isSupportPhoneCfg': 'true', 'isSupportElevatorControlCfg': 'true', 'isSupportSecurityMode': 'true', 'isSupportDeviceCommunication': 'true', 'isSupportKeyCfgPlanTemplate': 'true', 'isSupportSubModuleBacklight': 'true'}, 'IOTCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'supportChannelNum': '1000', 'isSupportIOTChannelCap': 'true', 'satusSearchTaskCap': {'maxResults': '30', 'filterType': {'@opt': 'all,online,offline'}}, 'channelConfigList': {'channelConfig': [{'unitType': 'outdoor', 'floorNumber': {'@min': '-10', '@max': '10'}, 'roomNumber': {'@min': '1', '@max': '99'}, 'isSupportZeroFloorNumber': 'true'}, {'unitType': 'indoor', 'floorNumber': {'@min': '0', '@max': '999'}, 'roomNumber': {'@min': '1', '@max': '9999'}}]}, 'isSupportConfigTemplate': 'true', 'isSupportConfigReport': 'true'}, 'isSupportGIS': 'true', 'isSupportCompass': 'true', 'isSupportFaceCaptureStatistics': 'false', 'isSupportAccessControlCap': 'true'}}
2024-10-21 10:52:07.996 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.25/ISAPI/Event/triggers
2024-10-21 10:52:07.996 DEBUG (MainThread) [custom_components.hikvision_next.isapi]
{'EventTriggerList': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'EventTrigger': {'id': 'vmd-1', 'eventType': 'VMD', 'EventTriggerNotificationList': {'EventTriggerNotification': {'id': 'center', 'notificationMethod': 'center', 'notificationRecurrence': 'beginning'}}}}}
2024-10-21 10:52:13.464 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.25/ISAPI/System/deviceInfo
2024-10-21 10:52:13.464 DEBUG (MainThread) [custom_components.hikvision_next.isapi]
{'DeviceInfo': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'deviceName': 'OUTDOOR STATION', 'deviceID': '7d49925b-4fc7-406b-a0ec-bc5e3359252f', 'deviceDescription': 'Vis', 'deviceLocation': 'STD-CGI', 'systemContact': 'STD-CGI', 'model': 'DS-KV8213-WME1(C)', 'serialNumber': 'DS-KV8213-WME1(C)0120230508RRAB0353909', 'macAddress': 'bc:5e:33:59:25:2f', 'firmwareVersion': 'V2.2.77', 'firmwareReleasedDate': 'build 240515', 'bootVersion': '33685581', 'bootReleasedDate': '1574159', 'hardwareVersion': '0x0', 'encoderVersion': 'V2.9', 'encoderReleasedDate': 'build 240223', 'deviceType': 'VIS', 'subDeviceType': 'villaDoorStation', 'telecontrolID': '88', 'supportBeep': 'true', 'supportVideoLoss': 'true', 'alarmOutNum': '2', 'alarmInNum': '4', 'RS485Num': '1', 'customizedInfo': None}}
2024-10-21 10:52:13.482 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.25/ISAPI/System/capabilities
2024-10-21 10:52:13.482 DEBUG (MainThread) [custom_components.hikvision_next.isapi]
{'DeviceCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'SysCap': {'isSupportDst': 'true', 'NetworkCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'isSupportWireless': 'true', 'isSupportNtp': 'true', 'isSupportFtp': 'true', 'isSupportHttps': 'true', 'SnmpCap': {'isSupport': 'false'}, 'isSupportEZVIZ': 'true', 'isSupportEhome': 'false', 'isSupportWirelessServer': 'true', 'isSupportEZVIZUnbind': 'true', 'isSupportSip': 'true'}, 'IOCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'IOInputPortNums': '4', 'IOOutputPortNums': '2'}, 'SerialCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'rs485PortNums': '0', 'supportRS232Config': 'false', 'rs422PortNums': '0', 'rs232PortNums': '1'}, 'AudioCap': 'true'}, 'SecurityCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'supportUserNums': '32', 'userBondIpNums': '0', 'userBondMacNums': '0', 'isSupCertificate': 'false', 'issupIllegalLoginLock': 'true', 'isSupportOnlineUser': 'true', 'isSupportAnonymous': 'false', 'isSupportStreamEncryption': 'false', 'securityVersion': {'@opt': '1,2', '#text': '1'}, 'keyIterateNum': '100', 'isSupportUserCheck': 'true', 'isSupportSecurityQuestionConfig': 'true', 'SecurityLimits': {'LoginPasswordLenLimit': {'@min': '1', '@max': '16', '#text': '16'}, 'SecurityAnswerLenLimit': {'@min': '1', '@max': '128', '#text': '128'}}, 'RSAKeyLength': {'@opt': '1024,2048', '#text': '2048'}, 'isSupportConfigFileImport': 'true', 'isSupportConfigFileExport': 'true', 'isIrreversible': 'true', 'salt': 'UK8PVU4G609NMG2IL1E5GCFE56JCELH86PEHKYD6ENT1JVZKCD69QLNB76OL759T', 'isSupportSecurityEmail': 'true', 'DoubleVerificationCap': {'isSupportUsersConfig': 'true', 'isSupportUsersPermissionConfig': 'true', 'isSupportFactoryReset': 'true'}, 'isSupportEncryptCertificate': 'true', 'isSupportCertificateCustomID': 'true'}, 'EventCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'isSupportHDFull': 'false', 'isSupportHDError': 'false', 'isSupportNicBroken': 'false', 'isSupportIpConflict': 'false', 'isSupportIllAccess': 'false', 'isSupportViException': 'false', 'isSupportViMismatch': 'false', 'isSupportRecordException': 'false', 'isSupportMotionDetection': 'true', 'isSupportVideoLoss': 'false', 'isSupportTamperDetection': 'false', 'isSupportHumanRecognition': 'true', 'isSupportFaceContrast': 'true'}, 'VideoIntercomCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'isSupportDeviceId': 'true', 'isSupportOperationTime': 'true', 'isSupportRemoteOpenDoor': 'true', 'isSupportKeyCfg': 'true', 'isSupportAlarmUploadCfg': 'true', 'isSupportSendCardCfg': 'true', 'isSupportCardSectorCheck': 'true', 'isSupportDeviceLanguageCfg': 'true', 'isSupportIssueCards': 'true', 'isSupportAlarmControlByPhone': 'false', 'isSupportWorkStatus': 'true', 'isSupportRingBackTone': 'true', 'isSupportPhoneCfg': 'true', 'isSupportElevatorControlCfg': 'true', 'isSupportSecurityMode': 'true', 'isSupportDeviceCommunication': 'true', 'isSupportKeyCfgPlanTemplate': 'true', 'isSupportSubModuleBacklight': 'true'}, 'IOTCap': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'supportChannelNum': '1000', 'isSupportIOTChannelCap': 'true', 'satusSearchTaskCap': {'maxResults': '30', 'filterType': {'@opt': 'all,online,offline'}}, 'channelConfigList': {'channelConfig': [{'unitType': 'outdoor', 'floorNumber': {'@min': '-10', '@max': '10'}, 'roomNumber': {'@min': '1', '@max': '99'}, 'isSupportZeroFloorNumber': 'true'}, {'unitType': 'indoor', 'floorNumber': {'@min': '0', '@max': '999'}, 'roomNumber': {'@min': '1', '@max': '9999'}}]}, 'isSupportConfigTemplate': 'true', 'isSupportConfigReport': 'true'}, 'isSupportGIS': 'true', 'isSupportCompass': 'true', 'isSupportFaceCaptureStatistics': 'false', 'isSupportAccessControlCap': 'true'}}
2024-10-21 10:52:13.491 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.25/ISAPI/Event/triggers
2024-10-21 10:52:13.491 DEBUG (MainThread) [custom_components.hikvision_next.isapi]
{'EventTriggerList': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'EventTrigger': {'id': 'vmd-1', 'eventType': 'VMD', 'EventTriggerNotificationList': {'EventTriggerNotification': {'id': 'center', 'notificationMethod': 'center', 'notificationRecurrence': 'beginning'}}}}}

@maciej-or
Copy link
Owner

@felipecrs I don't see any errors, does it work for you?

@felipecrs
Copy link
Author

Not really, it stays under the same situation:

image

And no error is thrown in the logs indeed.

@maciej-or
Copy link
Owner

ha, I found sth, we are close!

@maciej-or
Copy link
Owner

@felipecrs
Copy link
Author

Yay, it works!

chrome_80Gp33MIbU.mp4

@felipecrs
Copy link
Author

@maciej-or do you have some script to generate fixtures for you? I can try generating for my device.

@maciej-or
Copy link
Owner

yes please, all you need is to hit DOWNLOAD DIAGNOSTIC button and send the file

@felipecrs
Copy link
Author

@maciej-or
Copy link
Owner

sth went wrong all requests have 401 unauthorized status, did you change integration user access?

@felipecrs
Copy link
Author

Not really:

chrome_CVsbz4sSSN.mp4

config_entry-hikvision_next-01JATHQFSAS7NS9RAS04T5DS7A (1).json

@felipecrs
Copy link
Author

felipecrs commented Oct 22, 2024

This works:

curl --fail-with-body -sSL --digest -u admin:pass http://192.168.1.25/ISAPI/System/deviceInfo

Maybe authentication is different for Hikvision doorbells? But then how come the entities are working? Weird.

@maciej-or
Copy link
Owner

The same connection is used for entities and diagnostics. Weird indeed. Another wrong behaviour is you don't have picture for stream. It is displayed in the circle and on the video until stream starts.
pls check those endpoints

http://192.168.1.25/ISAPI/Streaming/channels/101/picture
http://192.168.1.25/ISAPIContentMgmt/StreamingProxy/channels/101/picture

in the web browser snapshot should appear
The integrations supports basic and digest auth, detects which is used.

@felipecrs
Copy link
Author

Additionally I found these logs:

This error originated from a custom integration.

Logger: custom_components.hikvision_next.isapi
Source: custom_components/hikvision_next/isapi.py:832
integration: Hikvision NVR / IP Camera (documentation, issues)
First occurred: 1:52:57 PM (8 occurrences)
Last logged: 1:58:57 PM

Unexpected exception | Cannot fetch state for alarm output 2 | Client error '404 Not Found' for url 'http://192.168.1.25/ISAPI/System/IO/outputs/2/status' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
Unexpected exception | Cannot fetch state for HDD | Client error '404 Not Found' for url 'http://192.168.1.25/ISAPI/ContentMgmt/Storage' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404

But I also found these:

2024-10-22 13:50:56.695 DEBUG (MainThread) [custom_components.hikvision_next.isapi] --- [GET] http://192.168.1.25/ISAPI/System/deviceInfo
2024-10-22 13:50:56.695 DEBUG (MainThread) [custom_components.hikvision_next.isapi]
{'DeviceInfo': {'@version': '2.0', '@xmlns': 'http://www.isapi.org/ver20/XMLSchema', 'deviceName': 'OUTDOOR STATION', 'deviceID': '7d49925b-4fc7-406b-a0ec-bc5e3359252f', 'deviceDescription': 'Vis', 'deviceLocation': 'STD-CGI', 'systemContact': 'STD-CGI', 'model': 'DS-KV8213-WME1(C)', 'serialNumber': 'DS-KV8213-WME1(C)0120230508RRAB0353909', 'macAddress': 'bc:5e:33:59:25:2f', 'firmwareVersion': 'V2.2.77', 'firmwareReleasedDate': 'build 240515', 'bootVersion': '33685581', 'bootReleasedDate': '1574159', 'hardwareVersion': '0x0', 'encoderVersion': 'V2.9', 'encoderReleasedDate': 'build 240223', 'deviceType': 'VIS', 'subDeviceType': 'villaDoorStation', 'telecontrolID': '88', 'supportBeep': 'true', 'supportVideoLoss': 'true', 'alarmOutNum': '2', 'alarmInNum': '4', 'RS485Num': '1', 'customizedInfo': None}}

Which indicates that System/deviceInfo is working fine even though diagnostics are returning 401.

@maciej-or
Copy link
Owner

maciej-or commented Oct 22, 2024

That's the question why by init deviceInfo returns valid data with status 200 and in diagnostic 401?
Errors 404 are fine, your doorbell just does not support those endpoints. There is no mass storage in your model and newer devices use different url for outputs status

@felipecrs
Copy link
Author

  1. Works, I can view image.jpeg:
$ curl --fail-with-body -sSL --digest -u 'admin:pass' http://192.168.1.25/ISAPI/Streaming/channels/101/picture --output image.jpeg

But doesn't work through the browser:

image

Which I suppose means Basic Auth isn't supported, only Digest.

  1. 404
$ curl --fail-with-body -sSL --digest -u admin:pass http://192.168.1.25/ISAPIContentMgmt/StreamingProxy/channels/101/picture

<!DOCTYPE html>
<html><head><title>Document Error: Not Found</title></head>
<body><h2>Access Error: 404 -- Not Found</h2>
<p>Can't locate document: /ISAPIContentMgmt/StreamingProxy/channels/101/picture</p>
</body>
</html>
curl: (22) The requested URL returned error: 404

@felipecrs
Copy link
Author

I believe the most reasonable explanation is that the integration isn't using the proper authentication method when collecting diagnostics.

@maciej-or
Copy link
Owner

you are right, I found small bug in authentication method detection
pls test https://github.com/maciej-or/hikvision_next/tree/fix/doorbell-initialization

@felipecrs
Copy link
Author

Weird. The same behavior was kept.

@mihaimdinca can you try it too?

@mihaimdinca
Copy link

I do not see any difference compared to previous iteration.

@maciej-or
Copy link
Owner

@felipecrs let's see what will happen if we disable basic auth detection
please comment out this line
https://github.com/maciej-or/hikvision_next/blob/fix/doorbell-initialization/custom_components/hikvision_next/isapi_client.py#L48
and restart HA

@felipecrs
Copy link
Author

I found this in the logs:

2024-10-23 15:00:40.534 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 377, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 563, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
  Invalid method encountered:

    b'\xe8'
      ^
2024-10-23 15:01:12.649 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 377, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 563, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
  Invalid method encountered:

    b'\xe8'
      ^
2024-10-23 15:01:24.164 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 377, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 563, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
  Invalid method encountered:

    b'\xe8'
      ^
2024-10-23 15:01:50.523 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 377, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 563, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
  Invalid method encountered:

    b'\xe8'
      ^
2024-10-23 15:02:13.890 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/System/deviceInfo
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/System/deviceInfo'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:13.896 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/System/capabilities
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/System/capabilities'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:13.903 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/System/IO/inputs/1/status
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/System/IO/inputs/1/status'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:13.912 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/System/IO/outputs/1/status
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/System/IO/outputs/1/status'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:13.920 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/System/Holidays
Client error '404 Not Found' for url 'http://192.168.1.25/ISAPI/System/Holidays'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
2024-10-23 15:02:13.933 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/System/Video/inputs/channels
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/System/Video/inputs/channels'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:13.940 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/ContentMgmt/InputProxy/channels
Client error '404 Not Found' for url 'http://192.168.1.25/ISAPI/ContentMgmt/InputProxy/channels'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
2024-10-23 15:02:13.950 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/ContentMgmt/Storage
Client error '404 Not Found' for url 'http://192.168.1.25/ISAPI/ContentMgmt/Storage'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404
2024-10-23 15:02:13.957 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/Security/adminAccesses
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/Security/adminAccesses'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:13.963 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/Event/triggers
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/Event/triggers'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:13.985 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/Event/triggers/scenechangedetection-1
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/Event/triggers/scenechangedetection-1'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:13.995 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/Event/notification/httpHosts
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/Event/notification/httpHosts'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:14.003 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/Streaming/channels/101
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/Streaming/channels/101'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:14.017 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/Streaming/channels/102
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/Streaming/channels/102'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:14.030 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/Streaming/channels/103
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/Streaming/channels/103'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
2024-10-23 15:02:14.041 INFO (MainThread) [custom_components.hikvision_next.isapi] --- [get] http://192.168.1.25/ISAPI/Streaming/channels/104
Client error '401 Unauthorized' for url 'http://192.168.1.25/ISAPI/Streaming/channels/104'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401

But I don't know if these errors are thrown because of the integration.

@felipecrs
Copy link
Author

If I clear the logs and then reload the integration, the error throws again:

Logger: aiohttp.server
Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:448
First occurred: 3:11:09 PM (1 occurrences)
Last logged: 3:11:09 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 377, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 563, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
  Invalid method encountered:

    b'\xe8'
      ^

Weird.

@maciej-or
Copy link
Owner

maciej-or commented Oct 23, 2024

does it occur after commenting out this line?
httpx.BasicAuth(self.username, self.password),

@felipecrs
Copy link
Author

  1. Commented out the BasicAuth line
  2. Restarted HA
  3. Re-added the device
  4. Same issue :(

That's too bad, the bug you had found actually made sense!

@felipecrs
Copy link
Author

I do not see any difference compared to previous iteration.

@mihaimdinca the device in fact works now, pretty much alright. That's a huge improvement lol. Maybe you forgot to restart your HA and re-add the integration after updating the branch?

@mihaimdinca
Copy link

I do not see any difference compared to previous iteration.

@mihaimdinca the device in fact works now, pretty much alright. That's a huge improvement lol. Maybe you forgot to restart your HA and re-add the integration after updating the branch?

I agree it works. I was referring to the previous test version when I said it is no different from the present one.I am getting the camera feed and the diagnostic section. It is a very nice start. I hope in the future we may also get motion sensor, call sensor, door switch and so on.

@mihaimdinca
Copy link

Or am I missing something?

@felipecrs
Copy link
Author

felipecrs commented Oct 23, 2024

No, I think we are on the same page then.

@maciej-or
Copy link
Owner

I found this home-assistant/core#124653
it looks the latest error is not related to the integration nor hikvision api

@felipecrs
Copy link
Author

Wow. That's crazy. Thank you.

@maciej-or
Copy link
Owner

hi @felipecrs the bug related to aiohttp is fixed in HA 2024.12.0 in the meantime new version of hikvision_next was released you can check both

@felipecrs
Copy link
Author

I think this means it's working:

image

I can stream video too. Yay!

Maybe someday we can also get some useful sensors or event entities, like button pressed or a switch to unlock the door. Thank you very much so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants