petrleocompel / hikaxpro_hacs

HACS repository of Hikvision Ax Pro integration for home assistant
MIT License
46 stars 5 forks source link

Unexpected error trying to integrate Ax Hub #72

Closed MnemoBRMC closed 1 year ago

MnemoBRMC commented 1 year ago

Hi I am trying to integrate my AX Hub and I get an Unexpected error In the integration dialog, I select "Use internal API lib (AXHub)", is that right?

This is what I find in the logs


Source: custom_components/hikvision_axpro/config_flow.py:178
Integration: hikvision_axpro
First occurred: 16:40:55 (2 occurrences)
Last logged: 16:44:24

Unexpected exception
Traceback (most recent call last):
  File "/config/custom_components/hikvision_axpro/hikax/hikax.py", line 38, in get_session_params
    session_cap = self.parse_session_response(response.text)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/hikax/hikax.py", line 66, in parse_session_response
    session_cap = SessionLoginCap.SessionLoginCap(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: SessionLoginCap.__init__() missing 1 required positional argument: 'session_id_version'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/hikvision_axpro/config_flow.py", line 178, in async_step_user
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/config_flow.py", line 151, in validate_input
    if not await hub.authenticate():
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/config_flow.py", line 116, in authenticate
    is_connect_success = await self.hass.async_add_executor_job(self.axpro.connect)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/hikax/hikax.py", line 93, in connect
    params = self.get_session_params()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hikvision_axpro/hikax/hikax.py", line 41, in get_session_params
    raise errors.IncorrectResponseContentError()
errors.errors.IncorrectResponseContentError: Response content is not in expected form.````
petrleocompel commented 1 year ago

AXHub internal lib is deprecated. Should not be used.

MnemoBRMC commented 1 year ago

Ok, but when I don't use it, it throws an invalid authentication error. I am using my user/pwd from hikconnect app.

petrleocompel commented 1 year ago

Yes but you have to be admin. Some users reported that when they do not use Admin user it does not work. Seems that normal user has no access to ISAPI.

petrleocompel commented 1 year ago

Well you are writing about Unexpected Error but not providing any logs...

MnemoBRMC commented 1 year ago

Sorry I am not sure what is exactly happening. There are no logs in Home Assistant but what I see is that my hikvision central device appears with several IPs in my router. When I open SADP there are two different entries with two IPs. Maybe that is part of the problem. When I try to add the integration, it sometimes throw me an Unexpected Error and sometimes Invalid Authentication, even the user/pwd is right. I am going to try to reboot it to see what happens SADP

MnemoBRMC commented 1 year ago

Ok, after rebooting I still have two IPs. Anyway if I try any of them, the error is Invalid Authentication. I am using as username and password the same credentials as in HikConnect app. As far as I know, the user is admin because is the only user I have. Is there any way to really check if the user has the proper admin rights?

petrleocompel commented 1 year ago

Well one IP will be ETH and second will be WiFi I guess.

During the setup try to check "debug output" and try again to get logs.

You can check in web UI of device.

MnemoBRMC commented 1 year ago

Ok, that makes sense, thanks for the explanation. I enabled debug output in the dialog but there are still no logs...

MnemoBRMC commented 1 year ago

Ok, I got it. Instead or using my hikvision account user (my email), I had to use "admin". Probably is somewhere is the documentation and I did not see it

petrleocompel commented 1 year ago

It can be difference with "AXPro" and "AXHub". Sadly this extension supports AXHub but cannot solve everything, since i have only AXPRO.

MnemoBRMC commented 1 year ago

Anyway is fantastic, I see now all my AX-hub sensors and I can now trigger a snapshot from my frigate cameras when the sensors status change. Thanks a lot