rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
385 stars 73 forks source link

Username, Password, or Address is wrong. #145

Open systxix opened 2 years ago

systxix commented 2 years ago

Version of the custom_component

Configuration


Add your logs here.

Describe the bug

While adding camera to HA i'm getting this error: "Username, Password, or Address is wrong." Using default username admin/admin

Are these cameras supported?

IPC-HFW1320S IPC-HFW1300S IPC-HFW2320R-ZS

Debug log


Add your logs here.
AndreTzerra commented 2 years ago

I have the same problem.

When I try to add my XVR5108HS I have the same problem. In the past I have managed to get a connection once. Last week I had to change my complete network IP range. (Migrated from 192.168.2.X to 10.11.1.X)

And now I can't get it to work again. I'm sure that I use the right Name, password IP and port settings. Below is the output from the Dahua log:

_File "/config/custom_components/dahua/client.py", line 657, in get response.raise_for_status() File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status raise ClientResponseError( aiohttp.clientexceptions.ClientResponseError: 500, message='Internal Server Error', url=URL('https://10.11.1.180:443/cgi-bin/magicBox.cgi?action=getMachineName')

When I go to https://10.11.1.180:443/cgi-bin/magicBox.cgi?action=getMachineName, I get "name=XVR".

intelwolf commented 2 years ago

For me it worked after changing the source code from client.py to below (in the custom_components folder). As it appeared my cam only provided that information after authentication and this fixed it:

_# self._base = "{0}://{1}:{2}".format(protocol, address, port) self.base = "{0}://{1}:{2}@{3}:{4}".format(protocol, username, password, address, port)

rroller commented 2 years ago

Thanks, this helps a lot. Can you try this (make sure to revert the code change)... When adding the cam, for the address do this... but your username and password... user:password@IP_ADDRESS for example...

admin:pass@192.168.1.203

AndreTzerra commented 2 years ago

The option : _self.base = "{0}://{1}:{2}@{3}:{4}".format(protocol, username, password, address, port) did not work for me.

For me the solution looks very simple: I used port 80 all the time. Let's give 443 one try. Thats it!

After deleting and reinstalling the component it works. 👍

intelwolf commented 2 years ago

That was my initial attempt (adding username:passwd to the address field). The result was that my camera got initialised without errors and all but I couldn't get the streams working. Makes sense I guess since the rtsp streams already have username password in it and using this method it would duplicate that.

systxix commented 2 years ago

Thanks, this helps a lot. Can you try this (make sure to revert the code change)... When adding the cam, for the address do this... but your username and password... user:password@IP_ADDRESS for example...

admin:pass@192.168.1.203

I can add camera like this but like intelwolf mentioned stream is not working.

si458 commented 2 years ago

have you tried:

  1. delete device/integration
  2. updating to the latest version 0.9.39
  3. enable debug in configuration.yaml
  4. reboot HA
  5. try adding the device again and then checking logs (also check the user/pass works in your browser works directy from the camera ip first)
systxix commented 2 years ago

This error originated from a custom integration.

Logger: custom_components.dahua Source: custom_components/dahua/client.py:670 Integration: Dahua (documentation, issues) First occurred: 14:40:44 (1 occurrences) Last logged: 14:40:44

Could not connect to Dahua device. For iMou devices see https://github.com/rroller/dahua/issues/6 Traceback (most recent call last): File "/config/custom_components/dahua/config_flow.py", line 177, in _test_credentials data = await client.get_machine_name() File "/config/custom_components/dahua/client.py", line 101, in get_machine_name return await self.get("/cgi-bin/magicBox.cgi?action=getMachineName") File "/config/custom_components/dahua/client.py", line 687, in get raise exception File "/config/custom_components/dahua/client.py", line 670, in get response.raise_for_status() File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('http://192.168.88.246:80/cgi-bin/magicBox.cgi?action=getMachineName')

si458 commented 2 years ago

401, message='Unauthorized',

you need to verify the user/pass is correct by going to the URL it shows directly in your browser, if the user/pass is correct you should get like a 404 error or 200 or something else, but not a 401 error

systxix commented 2 years ago

User and pass is correct. When opening http://192.168.88.246/cgi-bin/magicBox.cgi?action=getMachineName it asks for user/pass and then displays camera name=2A01ED7PAA00426

nbmi commented 2 years ago

As a critical initial step for those new to this, make sure your CGI service is enabled (System->Safety->SystemService->CGI Service).

I hadn't done this and could not connect to the camera at all after trying all suggestions in this thread. When I visited this location in browser (http://192.168.1.10/cgi-bin/magicBox.cgi?action=getMachineName) I got a 404. And after trying to add the integration, I would see a 404 error in the integration logs. But after enabling CGI, I was able to successfully add the camera to HA.

Tested on Dahua N43AM5Z

giedriuskilcauskas commented 2 years ago

After camera reset I was unable to setup camera in Integration, but while checking suggestion by @nbmi (which was Enabled, btw), I've noticed setting Private Protocol Authentication Mode (in the same location). Once I've changed to Compatibility Mode, it started working.

alnsiuenrasd commented 2 years ago

After exploring all of the suggestions provided here, I finally just reflashed home assistant and started all over. Once the Dahua integration was installed through HACS I was able to add all of my cameras with no issues. Perhaps this is an issue with Home Assistant?

gnkarn commented 2 years ago

i have tried everything mentioned above , but still the same error , indicating error with name password or address , the url test works ok from browser . something else i could try ?, tks

this is the log info

Traceback (most recent call last): File "/config/custom_components/dahua/config_flow.py", line 177, in _test_credentials data = await client.get_machine_name() File "/config/custom_components/dahua/client.py", line 101, in get_machine_name return await self.get("/cgi-bin/magicBox.cgi?action=getMachineName") File "/config/custom_components/dahua/client.py", line 687, in get raise exception File "/config/custom_components/dahua/client.py", line 670, in get response.raise_for_status() File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 500, message='Internal Server Error', url=URL('https://192.168.0.199:443/cgi-bin/magicBox.cgi?action=getMachineName')

so , it seams the url fails, but if i test the URL , result is success .

gnkarn commented 2 years ago

problem solved , it was port number 443 instead of 80

NicusorFlorinBaluta commented 1 year ago

hello, i have the same issue, but i can't find this CGI setting @nbmi is talking about i tried the other solutions and they didn't work my camera model is IPC-F42FE Can someone help me please? I managed to compose a working rtsp url, which i used in vlc without issue, so the ip/username/password are fine

si458 commented 1 year ago

hello, i have the same issue, but i can't find this CGI setting @nbmi is talking about i tried the other solutions and they didn't work my camera model is IPC-F42FE Can someone help me please? I managed to compose a working rtsp url, which i used in vlc without issue, so the ip/username/password are fine

Are u using special characters in tbe password? I found with one unit we have, it was fiddly with special characters so we changed it to a long number n letters one and it just worked then?

NicusorFlorinBaluta commented 1 year ago

no special characters, it's the default password. i also just noticed i cannot access the camera by entering the ip address into the browser

si458 commented 1 year ago

Have u tried https://THEIP ?

NicusorFlorinBaluta commented 1 year ago

Did now, still no spark :(