Closed jjmuriel closed 2 years ago
Hi, can you please follow the debugging guide so that I know what is the issue?
https://github.com/tomasbedrich/home-assistant-hikconnect/blob/main/DEBUGGING.md
In your case, please ensure you perform the login attempt to have it captured in the logs.
Hi, I followed this guide and sent you the logs to your email. Thanks.
It seems strange to me it tries to connect to US API, while you are probably located in Spain, right? Do you have any possible explanation, like VPN, DNS blocking, or..?
Moreover aren't there more logs to send? Maybe in this case it also helps if you send me your whole log file + config file, so that I can explain why it connects to US servers.
I'm located in South America and the Hik-Connect App was configurated with USA account. I don't use VPN. I'll send you my whole log and config file, but I have some configurations splited in several YAML files. Maybe, I have to change the account to my country? I'll try and post the result.
If I change the account to my country, I can't add my Hikvision Doorbell in the Hik-Connect App. Instead, with the USA account it works. So, I have to use USA account (no VPN).
Hm, could you please do nslookup api.hik-connect.com
from your computer and paste the result here?
This is the output:
Server: 192.168.111.5
Address: 192.168.111.5#53
Non-authoritative answer:
api.hik-connect.com canonical name = apiisa.hik-connect.com.
apiisa.hik-connect.com canonical name = apisa-hik-connect-1930596709.sa-east-1.elb.amazonaws.com.
Name: apisa-hik-connect-1930596709.sa-east-1.elb.amazonaws.com
Address: 54.233.110.148
Name: apisa-hik-connect-1930596709.sa-east-1.elb.amazonaws.com
Address: 18.228.49.130
Ok, then it seems clear.
We have to redirect user to API domain returned in login request, if Hikconnect service provides such hint.
Thanks for your bug report and cooperation.
Thank you @tomasbedrich .
Please try version number 1.1.1 and let me know.
Hi @tomasbedrich, Now I can login, but now:
This error originated from a custom integration.
Logger: custom_components.hikconnect
Source: custom_components/hikconnect/__init__.py:30
Integration: Hik-Connect (documentation, issues)
First occurred: 07:49:14 (4 occurrences)
Last logged: 07:49:51
Unexpected error fetching hikconnect data: unsupported operand type(s) for -: 'NoneType' and 'datetime.datetime'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 147, in _async_update_data
return await self.update_method()
File "/config/custom_components/hikconnect/__init__.py", line 41, in async_update
await relogin_if_needed()
File "/config/custom_components/hikconnect/__init__.py", line 30, in relogin_if_needed
needed = api.is_refresh_login_needed()
File "/usr/local/lib/python3.9/site-packages/hikconnect/api.py", line 130, in is_refresh_login_needed
return (self.login_valid_until - datetime.datetime.now()) < datetime.timedelta(
TypeError: unsupported operand type(s) for -: 'NoneType' and 'datetime.datetime'
Could you please provide logs again to my e-mail?
Sure, I just sent you the logs.
Can you please try version 1.1.2?
I did it, now there is not error, but I have 2 devices with the same name and no entities:
Device no. 1
Device no. 2
I have this video doorbell: https://us.hikvision.com/en/products/more-products/video-intercom/door-station/3-mp-outdoor-wi-fi-smart-doorbell-camera-ds-hd1 I sent you the log file again. Thank you @tomasbedrich .
Okay, I'm glad that you are able to log in, so this bug is fixed.
The issue what you mention is #15. This is expected behavior, because currently the integrations supports locks only. Unfortunately, given your setup, the integration is not going to be useful for you (at least until something else than locks is implemented).
I understand, thank you.
Hi, I'm typing my hik-connect username and password info but integration keeps rejecting me. The info works at hik-connect site.
Any idea what I doing wrong?
`This error originated from a custom integration.
Logger: custom_components.hikconnect.config_flow Source: custom_components/hikconnect/config_flow.py:26 Integration: Hik-Connect (documentation, issues) First occurred: 10:47:17 (2 occurrences) Last logged: 10:53:23
Hik-Connect login failed Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/hikconnect/api.py", line 75, 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 77, in login raise LoginError("Unable to parse session_id from response.") from e hikconnect.exceptions.LoginError: Unable to parse session_id from response. `
2022-01-12 10:47:17 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': 'USA', 'areaId': 314}}' 2022-01-12 10:47:17 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 75, 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 77, in login raise LoginError("Unable to parse session_id from response.") from e hikconnect.exceptions.LoginError: Unable to parse session_id from response.