dahua icon indicating copy to clipboard operation
dahua copied to clipboard

Camera entity becomes unavailable.

Open wgumaa opened this issue 2 years ago • 38 comments

Up till the latest update my 2 cameras were working fine. After the latest update I have noticed that the cameras become unavailable. I have 2 automations related to the cameras. 1 arms the motion detection at a certain hour in the evening and 1 that disarms them at a certain hour in the morning. However looking at the logs the times the cameras become unavailable is not near the automation times. They are random.

Have to reload the integration to make them work again.

Anyone experiencing the same issue?

wgumaa avatar Jun 11 '23 04:06 wgumaa

Same issues with the latest update of Dahua integration.

soulbrat avatar Jun 11 '23 09:06 soulbrat

It seems highly random. My AD410 goes completely unavailable, including the button entity which means I have no doorbell (the physical chime does not work). Was working without issue for 6 months before the last update.

Debugging logs arent an option in the integrations page. Please let me know if there is something I can do to contribute to this issue.

DarthElle13 avatar Jun 11 '23 12:06 DarthElle13

I’m noticing the same issue with an Amcrest AD410 doorbell. Within the past few weeks the Dahua integration will work after I reload it, but stops working after a few hours. I’m seeing thousands of “Exception fetching information from…” type error messages in the Home Assistant logs. If I reload the integration, it usually starts working again but the problem repeats. Prior to this, it was working great for 6+ months. My AD410 firmware is still on the original (did not update to the recently released version).

I’m going to try downgrading to 0.9.44 now to see if that resolves it.

shred86 avatar Jun 11 '23 14:06 shred86

I meant to say the latest HA update

wgumaa avatar Jun 11 '23 17:06 wgumaa

+1

thornygravy avatar Jun 11 '23 23:06 thornygravy

Same here with the AD410. Downgrading does solve it! Also installed the new firmware but that didn't make a difference.

danieldotnl avatar Jun 12 '23 04:06 danieldotnl

Same issue since last HA update. I think it is the HA update not the DI update here, but I could be wrong. Timing has been since the recent HA version upgrade. Cameras go inactive after some time. A full unplug and restart fixes for a little while.
NVR=N54B3P Cameras = N85DL6Z

Other addon had Python deprecated issues as they upgraded python in HA.

mcdhome avatar Jun 12 '23 22:06 mcdhome

Happened for the first time for me before I updated to 2023.6 so definitely not just due to the HA update

DarthElle13 avatar Jun 12 '23 22:06 DarthElle13

After downgrading the Dahua Integration to 0.9.44, it's been running for over 24 hours now without seeing the issue. Before, it would happen within a few hours.

shred86 avatar Jun 13 '23 00:06 shred86

Just some more information on my issue. Ever since I started using this integration, I would get occasional timeout errors such as the following:

2023-06-12 15:44:05.440 WARNING (MainThread) [custom_components.dahua] TimeoutError fetching information from http://my-cam-ip:80/cgi-bin/configManager.cgi?action=getConfig&name=Lighting[0][0]

These would occur maybe a couple times a day but everything worked as expected. I think when I upgraded the Dahua Integration to the latest version, 0.9.46, is when I started noticing my Amcrest AD410 was becoming unavailable after a few hours and I would see thousands of the log entry above. I also use the Scrypted application to integrate my AD410 with HomeKit and while I could still access the video feed from the camera, I would no longer receive doorbell event presses. In other words, the AD410 became completely unavailable in Home Assistant, but was still partial available in Scrypted (video feed but no doorbell events). If I reloaded the integration in both Home Assistant and Scrypted, it would work as expected for a few hours before repeating this behavior.

As I mentioned above, after downgrading this integration to 0.9.44, everything has been working "normal" like before, both with this integration and Scrypted. I am still seeing a couple timeout errors in the logs but not the thousands of entries like before and everything is still functional.

shred86 avatar Jun 13 '23 01:06 shred86

Also downgraded to 0.9.44. Will update with results in the next couple of days.

DarthElle13 avatar Jun 13 '23 02:06 DarthElle13

Same here. If you turn cameras router off then it never comes back in 0.9.46. Downgraded to 0.9.44 - it works fine and cameras comes back after turning off and on.

mmib avatar Jun 13 '23 09:06 mmib

Just wanted to confirm, hit by it too after updating. Worked correctly for months before that, also reverted to the 0.9.44 version and hoping it doesn't return.

intermittech avatar Jun 13 '23 21:06 intermittech

I am having the same issue with my doorbell AD410. In the meantime I just created an automation to reload the integration when the doorbell becomes unavailable.

kafka0 avatar Jun 14 '23 07:06 kafka0

same with a VTO 2202F device

pollinolas avatar Jun 15 '23 06:06 pollinolas

Same here. I have two IPC-HDW3849H-AS-PV camera's and two DHI-VTO2211G-P intercom devices. Reloading the configuration seems to fix it. Let me know if I can upload debug logging.

p2baron avatar Jun 17 '23 17:06 p2baron

In Home assistant, you can script the quick HA reload that will fix the camera connection when the NVR or cameras are restarted. Basically I restart my NVR every day, wait 10 minutes then run a Home Assistant service call to "Home Assistant Supervisor: Reboot the host system." and this gets all the cameras reconnected just fine until this bug is resolved.

mcdhome avatar Jun 17 '23 17:06 mcdhome

A few commits were released in the latest version (they were not written by my but by other community members who fixed a few bugs or added features).

I'm wondering if this one is at play here - https://github.com/rroller/dahua/commit/62c2def58596805c0e7f434b1d5f5421ba064f4b

Can anyone having this issue try without this commit?

rroller avatar Jun 18 '23 00:06 rroller

I reverted that commit in https://github.com/rroller/dahua/releases/tag/0.9.47

Can someone please try it?

rroller avatar Jun 18 '23 00:06 rroller

same issue here with serie 3 and 5 since. I will dl the debug version

ptschi avatar Jun 18 '23 11:06 ptschi

@rroller same error after update

This is the log:

2023-06-18 15:58:51.322 WARNING (MainThread) [custom_components.dahua] TimeoutError fetching information from https://192.168.188.53:443/cgi-bin/configManager.cgi?action=getConfig&name=Lighting[9][2] 2023-06-18 15:58:51.327 WARNING (MainThread) [custom_components.dahua] Failed to sync device state for 192.168.188.53. See README to enable debug logs to get full exception 2023-06-18 15:58:51.331 DEBUG (MainThread) [custom_components.dahua] Failed to sync device state for 192.168.188.53 Traceback (most recent call last): File "/config/custom_components/dahua/client.py", line 746, in get response = await auth.request("GET", url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/dahua/digest.py", line 50, in request return await self._handle_401(response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/dahua/digest.py", line 151, in _handle_401 return await self.request( ^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/dahua/digest.py", line 46, in request response = await self.session.request(method, url, headers=headers, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 560, in _request await resp.start(conn) File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 899, in start message, payload = await protocol.read() # type: ignore[union-attr] ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 616, in read await self._waiter asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/config/custom_components/dahua/init.py", line 325, in _async_update_data results = await asyncio.gather(*coros) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/dahua/client.py", line 217, in async_get_config_lighting return await self.async_get_config("Lighting[{0}][{1}]".format(channel, profile_mode)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/dahua/client.py", line 200, in async_get_config return await self.get(url) ^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/dahua/client.py", line 758, in get raise exception File "/config/custom_components/dahua/client.py", line 742, in get async with async_timeout.timeout(TIMEOUT_SECONDS): File "/usr/local/lib/python3.11/site-packages/async_timeout/init.py", line 129, in aexit self._do_exit(exc_type) File "/usr/local/lib/python3.11/site-packages/async_timeout/init.py", line 212, in _do_exit raise asyncio.TimeoutError TimeoutError 2023-06-18 15:58:51.339 ERROR (MainThread) [custom_components.dahua] Error fetching dahua data: 2023-06-18 15:58:51.341 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 24.175 seconds (success: False) 2023-06-18 15:58:51.349 WARNING (MainThread) [custom_components.dahua] TimeoutError fetching information from https://192.168.188.53:443/cgi-bin/configManager.cgi?action=getConfig&name=SmartMotionDetect

stefanoferrario avatar Jun 18 '23 13:06 stefanoferrario

Can you all list your camera models? I'd like to see if there's a certain type of camera having issues. I'm having a hard time reproducing this.

rroller avatar Jun 18 '23 20:06 rroller

@rroller It is an NVR. The model is DHI-NVR5216-16P-I. I noticed that sometimes are correctly load and motion detected is ok, other times are "not available".

stefanoferrario avatar Jun 18 '23 20:06 stefanoferrario

I'm wondering if this PR was at play then - https://github.com/rroller/dahua/pull/242

rroller avatar Jun 18 '23 20:06 rroller

Before 0.9.45 version I need to modify plugin code because was detected as doorbell and I receive no alarms. Not sometimes I receive alarms so I think #242 issue is solved.

stefanoferrario avatar Jun 18 '23 20:06 stefanoferrario

I've been running 0.9.47 for several hours now and haven't experienced the issue I mentioned before. I'll keep on eye on it but so far, so good. This is with an Amcrest AD410 doorbell.

shred86 avatar Jun 18 '23 22:06 shred86

I noticed in the log also this error image

I don't understand if could be related

stefanoferrario avatar Jun 19 '23 08:06 stefanoferrario

For anyone else currently having this issue (reverting to the older version did not fix it for me, still goes unavailable sometimes) I've created a little automation for myself which will trigger a reload of the integration, so far this seems to be working fine for me doing this manually so this automated way should hopefully hold us over until the bug is squashed. Having a non-working doorbell is annoying. ;) automation

intermittech avatar Jun 20 '23 18:06 intermittech

Me too still having problem with cameras. After home assistant start all cameras are ok and motion detection too is ok. After hours some cameras become unavailable and trying to reloading I have timeout error Please, any solution?

stefanoferrario avatar Jun 21 '23 06:06 stefanoferrario

I also noticed that only some motion alarms are not available others still working. I also try removing all my cameras and add them again

stefanoferrario avatar Jun 21 '23 06:06 stefanoferrario