Open pswel1 opened 2 months ago
I cobbled together a ghetto fix to camera.py, the source of the error, basically giving it a chance to miss a couple times and perhaps spacing out API requests more. I don't know if it's a "fix" or a "workaround" so I probably won't do a PR, unless it's wanted
async def async_camera_image(self, width: int | None = None, height: int | None = None):
"""Return a still image response from the camera."""
retries = 3
delay = 0.25
for attempt in range(retries):
try:
# Try to fetch the snapshot
return await self._coordinator.client.async_get_snapshot(self._channel_number)
except Exception as e:
# Log the error with attempt count
_LOGGER.warn(f"Attempt {attempt + 1} failed to get snapshot from channel {self._channel_number}: {str(e)}")
# Wait before retrying
if attempt < retries - 1:
await asyncio.sleep(delay)
else:
_LOGGER.warn(f"All attempts failed; returning None")
return None # or perhaps a stock image could be used
clean logs for 24 hours so I'll call it "good enough" haha
Just here to say Thank You for the above. I was in a similar boat with same error basically. Trying out your code now. Hopefully the ghetto fix works long term :)
Thank you again
With regards to your specific issue, the HTTP/1.1 500 Internal Server Error
when fetching snapshots is a broader issue that commonly affects Dahua-based IPCs. This fix
helped me to resolve the same issue. If you happen to be using an NVR then fixing the camera resolves the issue on the NVR. I also reduced the snapshot generation time to two seconds to reduce the chance of an incomplete snapshot. Snapshots are now reliably generated.
It would though be nicer if this and the error encountered in #365 were handled more gracefully.
Encountering repeated ClientResponseError and HttpProcessingError with the Dahua camera integration in Home Assistant. Errors occur when attempting to fetch snapshots from the camera. The log indicates issues with parsing the HTTP response from the camera at
/cgi-bin/snapshot.cgi
. It appears the integration may not be handling certain HTTP response statuses or headers correctly. I'm a longtime fan, but out of my depth on potential fixes or updates needed in the integration code or camera settings.Latest Dahua integration and HA 4/'24, using VTO2202F camera. Thanks for any help :)