tomasbedrich / home-assistant-hikconnect

A Home Assistant integration to communicate with Hikvision smart doorbells via Hik-Connect cloud.
43 stars 10 forks source link

Cannot login #9

Closed beccsjb closed 3 years ago

beccsjb commented 3 years ago

Im having issues right at the start with logging in when the integration is first launched.

my login credentials are correct as verified by logging in via the hik connect website.

tomasbedrich commented 3 years ago

Hi, would you mind helping me with debugging on your side? I need you to add this to your Home Assistant config:

logger:
  logs:
    hikconnect: debug
    custom_components.hikconnect: debug

Please send me the logs so that I know what is wrong. Also a few screenshots may be helpful. Please send it to e-mail ja@tbedrich.cz. Beware there are potentially sensitive info there: session_id, refresh_session_id + your intercom device ID + serial number.

tomasbedrich commented 3 years ago

Logs provided by @beccsjb:

# 2021-10-03 22:34:29 DEBUG (MainThread) [hikconnect.api] Got login response '{'meta': {'code': 1100, 'message': '客户端需要重定向用户请求域名(海外)', 'moreInfo': None}, 'loginArea': {'apiDomain': 'apiius.hik-connect.com', 'webDomain': 'ius.hik-connect.com', 'areaName': 'Australia', 'areaId': 501}}'
# 2021-10-03 22:34:29 ERROR (MainThread) [custom_components.hikconnect.config_flow] Hik-Connect login failed
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/hikconnect/api.py", line 70, in login
session_id = res_json["loginSession"]["sessionId"]
KeyError: 'loginSession'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/config/custom_components/hikconnect/config_flow.py", line 39, in async_step_user
await validate_input(self.hass, user_input)
File "/config/custom_components/hikconnect/config_flow.py", line 26, in validate_input
await api.login(data["username"], data["password"])
File "/usr/local/lib/python3.9/site-packages/hikconnect/api.py", line 72, in login
raise LoginError("Unable to parse session_id from response.") from e
hikconnect.exceptions.LoginError: Unable to parse session_id from response.
tomasbedrich commented 3 years ago

Based on my understanding of logs, it could be because of previously hardcoded API URL. It was fixed in 7ee9931179f0f0f44f99871fd1d8a25aa04a08e5. Can you please try the new version and let me know?

beccsjb commented 3 years ago

G'day Tomas, Yes, the new version has fixed the error i was getting. I can now login! Thank you VERY much.

Do you have any plans to include other devices in this integration? We use alot of the Hikvision Face Recognition terminals and currently use ASAPI get and calls for control. Would be awesome to have direct integration!

Awesome work and thank you for the time you've taken on both making this and for the great support you've given me :)

tomasbedrich commented 3 years ago

Glad to hear!

You can track new features planned here: https://github.com/tomasbedrich/home-assistant-hikconnect/issues Most notably I want to add this one: #6.

Unfortunately, I don't have any face recognition terminals available to connect and experiment, therefore I cannot add them to the integration.