RenierM26 / ha-ezviz

Ezviz component for HASSIO, testing latest additions to official integration. (The few I work on at least)
GNU General Public License v3.0
44 stars 21 forks source link

Cannot login #2

Open khuongkd opened 3 years ago

khuongkd commented 3 years ago

Can you help to resolve this login issue?

Error while setting up ha-ezviz platform for camera Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/ha-ezviz/camera.py", line 50, in setup_platform ezviz_client.login() File "/usr/local/lib/python3.8/site-packages/pyezviz/client.py", line 326, in login self._login() File "/usr/local/lib/python3.8/site-packages/pyezviz/client.py", line 97, in _login self._csrfToken = self._session.cookies['AS_SessionID'] File "/usr/local/lib/python3.8/site-packages/requests/cookies.py", line 328, in __getitem__ return self._find_no_duplicates(name) File "/usr/local/lib/python3.8/site-packages/requests/cookies.py", line 394, in _find_no_duplicates raise CookieConflictError('There are multiple cookies with name, %r' % (name)) requests.cookies.CookieConflictError: There are multiple cookies with name, 'AS_SessionID'

khuongkd commented 3 years ago

@RenierM26 can you help to check it?

RenierM26 commented 3 years ago

Hi There,

Could you please send me the camera section (Without sensitive info : camera serials and passwords) in your configuration.yaml file? Looks like there's multiple logins generating a duplicate cookie. (There are multiple cookies with name, 'AS_SessionID')

redonionking commented 3 years ago

having the same issue. camera:

khuongkd commented 3 years ago

Hi There,

Could you please send me the camera section (Without sensitive info : camera serials and passwords) in your configuration.yaml file? Looks like there's multiple logins generating a duplicate cookie. (There are multiple cookies with name, 'AS_SessionID')

Yes. Have multiple cookies because having double login requests: login to ieu.ezvizlife.com then continue login to isgp.ezvizlife.com (issue related to user region. I'm in Vietnam). we should update API Domain as an input parameter at here https://github.com/RenierM26/pyEzviz/blob/master/pyezviz/client.py#L16

[<Cookie ASG_Au=0oo6iWtWb8qpwBXGUrleyQXf5CWKjHh6Z9pi7K%2BZ3pOABoSKF6zJP2R8zjwxh6lq6CZbnPqtu7PbBiRxtPEPFnGReiArJrCvxhEmSo2LXbnCYzfWeF5jgT4pyAqQoX0zy3QEOnsqVyp9K08eXcxkLz6UQgsDU0L1V9r3F0DK3XNKl4lTCYoYl8MzK%2FWhzyxiNPMrEwUZRcSVFik%2FEgfazNIgBNPSdb9%2FTBLqxTbabrwgmz3J79waNU2vgjGU9cRu%2Bl4MVjAfwHakIR65vNoc3i6vujgIUdU1%2F7Wu0NSW%2Be8%3D for .ezvizlife.com/>, <Cookie ASG_Auc=837891311 for .ezvizlife.com/>, <Cookie ASG_Aus=BE8yazisoxGdiMhZ44bLIrafBMUUNWeKuWiO6dOCcoltKklqdONHZWDSAlBYb%2FdM7nfiuknmMe%2F4Y66nQB37nw%3D%3D for .ezvizlife.com/>, <Cookie ASG_AuthApp=6lTNEt625wzCSChvOn%2F6KBVeSSLJfP81QKiVmiYE2QrSE5SWzB4fSOBmutRk4%2FqV2qVCHnNLJmUpxRfK24d%2FyPvtLr0ESJ4OfyCIOKt%2FPJaKXDZrX%2B0dFb%2Bbecq9AINu2Iv66wojmWUd3%2BaJdO0BnObDrq5JNu69M0zz7sdNkpLc9lmxv%2FKbJuT6A5CSRAyvit9qzsKIIKv14kx%2FWZkcIg%3D%3D for .ezvizlife.com/>, <Cookie ASG_DisplayName=figfdq for .ezvizlife.com/>, <Cookie ASG_INS=c63bea66130e74c59929451403c79335 for .ezvizlife.com/>, <Cookie ASG_SS=a1c479fb88b0491faac1c831d5317456 for .ezvizlife.com/>, <Cookie CLOUDSERVICEBUYSHIELDCOOKIE=0 for .ezvizlife.com/>, <Cookie CLOUDSERVICESHIELDCOOKIE=0 for .ezvizlife.com/>, <Cookie DDNSCOOKIE=a1c479fb88b0491faac1c831d5317456%2Ca1c479fb88b0491faac1c831d5317456%2Cfigfdq%2Cfigfdq%2C7%2C5%2C10%2C108%2Cmesgp.ezvizlife.com%3A8155%2C0%2C1609212885871%2C1.55.166.151%2C0 for .ezvizlife.com/>, <Cookie USERNAME=figfdq for .ezvizlife.com/>, <Cookie AS_Apps=4e4148ba90184a7cbd81 for euauth.ezvizlife.com/>, <Cookie AS_Au=x0F83KPegq6j3S6OMORDoph2ZggTbbCY3m3WR3xsDtjk9aVidXBjzvmw9w2VDpsl9acZQF3uMfhBlpXQQXLk9Rc1A2L-NXY9A8Q70O4gZtdnRtb0go8tPRZ7_7zXEiEv for euauth.ezvizlife.com/>, <Cookie AS_Auc=2761408692 for euauth.ezvizlife.com/>, <Cookie AS_Aus=AX04lONgzIk0JjVi5F9PeiYprLJHzLAjLCPozdMXEzg5tWPec3cAhbdBMrhn9l38aMrYdEFCVk6z3qGGKXEP2A for euauth.ezvizlife.com/>, <Cookie AS_LastUser=840972426218 for euauth.ezvizlife.com/>, <Cookie AS_Type=Default for euauth.ezvizlife.com/>, <Cookie AS_AppID=4e4148ba90184a7cbd81 for ieu.ezvizlife.com/>, <Cookie AS_INS=c63bea66130e74c59929451403c79335 for ieu.ezvizlife.com/>, <Cookie AS_Ran=6422765700665597687 for ieu.ezvizlife.com/>, <Cookie AS_SessionID=a1c479fb88b0491faac1c831d5317456 for ieu.ezvizlife.com/>, <Cookie AS_Spl=true for ieu.ezvizlife.com/>, <Cookie AS_UserID=b4666d6e15844f11a01bf2497a844a53 for ieu.ezvizlife.com/>, <Cookie AS_Username=figfdq for ieu.ezvizlife.com/>, <Cookie PMSCOOKIE="" for ieu.ezvizlife.com/>, <Cookie STORAGESESSION=hik%24shipin7%23TEMP%23USK%23a1c479fb88b0491faac1c831d5317456 for ieu.ezvizlife.com/>, <Cookie STUNIPCOOKIE=49.51.172.104%3A6002%2C49.51.172.128%3A6003 for ieu.ezvizlife.com/>, <Cookie USERIPCOOKIE=10.201.13.120 for ieu.ezvizlife.com/>, <Cookie AS_INS=c63bea66130e74c59929451403c79335 for isgp.ezvizlife.com/>, <Cookie AS_SessionID=a1c479fb88b0491faac1c831d5317456 for isgp.ezvizlife.com/>, <Cookie AS_UserID=b4666d6e15844f11a01bf2497a844a53 for isgp.ezvizlife.com/>, <Cookie AS_Username=figfdq for isgp.ezvizlife.com/>, <Cookie JSESSIONID=52F83A81F86A1514166E0BFCE79365EB for isgp.ezvizlife.com/>, <Cookie PMSCOOKIE="" for isgp.ezvizlife.com/>, <Cookie STORAGESESSION=hik%24shipin7%23TEMP%23USK%23a1c479fb88b0491faac1c831d5317456 for isgp.ezvizlife.com/>, <Cookie STUNIPCOOKIE=150.109.178.162%3A6002%2C150.109.183.230%3A6003 for isgp.ezvizlife.com/>, <Cookie USERIPCOOKIE=1.55.166.151 for isgp.ezvizlife.com/>]

RenierM26 commented 3 years ago

Hi khuongkd,

I've added support for setting the region via the configuration.yaml file. Could you please test?

Add this line to your configuration.yaml file, under the username and password for the ezviz platform:

username: adsfasdf@ds.asd password: somepassword@1 region: sgp

RenierM26 commented 3 years ago

The integration setup will ask you to specify a region code. I have rewritten the integration based on the latest hass platform framework.

Just note, there are a few changes so this might need some manual intervention.

cepxuo commented 3 years ago

Hi! I have exact the same error. I don't know what to chose in region settings (now it is "eu" in the integrtion config). The mobile app says my region is Uzbekistan.

cepxuo commented 3 years ago

Update: I have used "sgp" region and login succeded, however now I have followinf error:

Logger: homeassistant.config_entries Source: helpers/entity_component.py:155 First occurred: 0:25:24 (5 occurrences) Last logged: 0:25:24

Error setting up entry 1dqpnh for camera Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 236, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/usr/src/homeassistant/homeassistant/components/camera/init.py", line 319, in async_setup_entry return await hass.data[DOMAIN].async_setup_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 155, in async_setup_entry raise ValueError("Config entry has already been setup!") ValueError: Config entry has already been setup!

I also have ezviz_cloud setop in configuration.yaml. Should I remove it?

cepxuo commented 3 years ago

Upd2: removing the following from configuration.yaml, followed by reboot, did not help:

ezviz_cloud:
  cameras:
    XXXXXXXXX:
      username: !secret uname
      password: !secret doorbell_pwd
RenierM26 commented 3 years ago

Hi There,

You can ignore the "File "ValueError: Config entry has already been setup!" warning on hassio startup. The integration should work. I also get this error.

I need to build config check into the platform setup routine to prevent this message. Hassio handles it without issue though and the error only appears on startup.

cepxuo commented 3 years ago

You can ignore the "File "ValueError: Config entry has already been setup!" warning on hassio startup. The integration should work. I also get this error.

Unfortunately, I don't see the camera in the system. I have added back the above lines in configuration.yaml and rebooted. Should I add anyhing elsse in camera: section?

RenierM26 commented 3 years ago

Hi cepxuo,

Could you please try to open : http://ieu.ezvizlife.com/ in a web browser? It should redirect to the correct auth url for your country. from the auth url we should be able to determine the country code.

cepxuo commented 3 years ago

Hi ReinerM26!

I have been redirected to https://euauth.ezvizlife.com/signIn?from=4e4148ba90184a7cbd81&r=8468399199119028021&returnUrl=plugin&host=ieu.ezvizlife.com

And after login I hve been redirected to: https://isgp.ezvizlife.com/user/userAction!goToMyShipin7.action

RenierM26 commented 3 years ago

sgp should be your country code. Would you mind testing?

cepxuo commented 3 years ago

I would love to test and to assist you with the project. What do I need to do?

RenierM26 commented 3 years ago

HI cepxuo,

You'll need to remove the integration and readd it. You'll then be able to specify the country code on the first config page.

Please enter sgp under region. (instead of eu)

cepxuo commented 3 years ago

Hi RenierM26!

It is already set to "sgp" as I mentioned here. Should I re-add integration anyway?

RenierM26 commented 3 years ago

Hi Cepxuo,

I've added some exception handling code for duplicate AS_Session cookie. This might solve your problem.

Could you please try release 0.0.2.6 ?

From what i can see, ezviz redirects correctly to most regions but this causes a duplicate session cookie. If that's your problem then the new release should solve the issue.

cepxuo commented 3 years ago

I have updated to release 0.0.2.6 and the error is not shown in logs anymore. However I still don't see camera object.

tnTano commented 3 years ago

Hi, where i can find logs? i have hassio and i need to know where are the problem because when i create the integration i use the eu region but it do not ask me for the 2fact auth and i cannot access my cam

thanks

RenierM26 commented 3 years ago

Hi There, @tnTano , The integration doesn't support 2fa auth or encryption yet.

@cepxuo , Would you please be so kind as to share your camera model numbers? It might be a category i need to add on the api.

cepxuo commented 3 years ago

Hi folks! @RenierM26 The camera model is CS-DP1-A0-4A1WPFBSR

RenierM26 commented 3 years ago

Hi Cepxuo,

I see you have a type of camera that the API doesn't yet support. I'll add it but just need some info from you.

Could you please run the pyezviz api and send me the info? Should be something like this from your Homeassistant cli. (You'll need to disable protection)

docker exec -it homeassistant /bin/bash python pyezviz -u login@ezviz.com -p PASSWORD camera --serial C234234 status

or you could run it from a PC/Mac.

pip install pyezviz python pyezviz -u login@ezviz.com -p PASSWORD camera --serial C234234 status

cepxuo commented 3 years ago

Hi @RenierM26

The result is an HTML output (attached), and it looks like it did not find something.

status.zip

I also tried pyezviz -u username -p password devices status and got the following: ('Impossible to load the devices, here is the returned response: %s ', '{"cameraInfos":[],"meta":{"code":200,"message":"操作成功","moreInfo":{}},"page":{"offset":0,"limit":8,"totalResults":0,"hasNext":false},"deviceInfos":[]}')

RenierM26 commented 3 years ago

@cepxuo,

1) Are you using shared cameras on your profile? Are you using the master account if this is the case. 2) Does your camera show up in the ezviz mobile app?

cepxuo commented 3 years ago

@RenierM26 ,

  1. No, thecamera is used only in my account
  2. Yes, the camera is show up in my mobaile app. I also can see it in Internet Explorer when I login here
RenierM26 commented 3 years ago

Hi There @cepxuo,

Have you tried the latest version?

cepxuo commented 3 years ago

Have you tried the latest version?

Hi! I have tried the latest version and re-installing the integration. Now I have 1 device available, but this is just alarm. Still no camera is shown.

RenierM26 commented 3 years ago

Hi @cepxuo ,

I need some info in order to resolve this issue.

Would one you be able to share a json dump? (Just find and replace the camera serial numbers in the output for privacy reasons it shouldn't be shared on a public forum)

1) Just login to this site first, before opening the url above (assuming EU server here): https://ieu.ezvizlife.com/

2) You should be able to open this page in IE or Safari. Is should automatically start downloading a .json file. https://apiieu.ezvizlife.com/v3/userdevices/v1/resources/pagelist?groupId=-1&limit=30&offset=0&filter=CLOUD%2CTIME_PLAN%2CCONNECTION%2CSWITCH%2CSTATUS%2CWIFI%2CNODISTURB%2CKMS%2CP2P%2CTIME_PLAN%2CCHANNEL%2CVTM%2CDETECTOR%2CFEATURE%2CUPGRADE%2CVIDEO_QUALITY%2CQOS

cepxuo commented 3 years ago

Hi @RenierM26

I have logged in the webapp (from link 1) and able to see my camera there. Then I pasted link 2 and downloaded the json file, but it shows no resources. Please see the file attached.

pagelist.zip

PS: I tried to remove "filter" from the 2d URL, but the file I received is the same.

RenierM26 commented 3 years ago

Hi @cepxuo,

It looks like the Doorbell cameras work in a totally different way. I need more info to add this to the integration.

Have you ever used https://mitmproxy.org/ or fidler?

elifqaoui commented 3 years ago

Hi @RenierM26 and All,

First thanks for the reposity. I tried with the two options :

both of them didnot work for me, i've tried also to connect to https://ieu.ezvizlife.com/, whitout success neither, i got the following msg : ezviz_issue

in the ezviz app, the region : Morocco I tried to change the region setting but i can't! remove the app and install it again not solve the issue.

i've got 4 cameras and Doorbell from ezviz brand :(

the error in logs is

Traceback (most recent call last):
File "/config/custom_components/ezviz_cloud/config_flow.py", line 203, in async_step_user
return await self._validate_and_create_auth(user_input)
File "/config/custom_components/ezviz_cloud/config_flow.py", line 82, in _validate_and_create_auth
ezviz_token = await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/ezviz_cloud/config_flow.py", line 56, in _get_ezviz_client_instance
ezviz_token = ezviz_client.login()
File "/usr/local/lib/python3.9/site-packages/pyezviz/client.py", line 604, in login
return self._login()
File "/usr/local/lib/python3.9/site-packages/pyezviz/client.py", line 122, in _login
self._token["session_id"] = str(json_result["loginSession"]["sessionId"])
KeyError: 'loginSession'

[EDIT] : I've check with VLC Media and i can visualize my cam with rstp. [/EDIT]

Thansk for help Hicham

tbaumann commented 9 months ago

in the ezviz app, the region : Morocco I tried to change the region setting but i can't! remove the app and install it again not solve the issue.

I was able to log in via the default EU api with region Morocco. Looks like they use the EU datacenter for morocco.

Unfortunately changing regions is not supported, one must re-create the account in the right region. https://support.ezviz.com/faq/article/How-can-I-change-the-account-region