Open GaryOkie opened 1 year ago
UPDATE: Overnight a perfectly working different camera suddenly failed with this exact error. 2858 times and counting! It had the exact same reduced response to the VideoInOptions payload as above.
Logger: homeassistant.helpers.entity
Source: components/amcrest/camera.py:641
First occurred: February 15, 2023 at 8:36:23 PM (2858 occurrences)
Last logged: 8:31:59 AM
Update for camera.frontdrive failed
Problem still occurring with 2 Dahua IPC-T5442T-ZE cameras updated with latest firmware.
Only resolution (other than a software update) is to reset camera to factory defaults and restore a config backup that gets it 90% reconfigured properly.
On occasion a camera doesn't respond with all the expected values. Ideally the code should check for unexpected values and handle them gracefully.
On several occasions I've seen a perfectly operating camera not being able to initialize in Home Assistant with this index out of range error. I've seen reports from others that have experienced this as well - such as: https://github.com/home-assistant/core/issues/30216
I've tracked this problem down to the async_get_day_night_color call expecting VideoInOptions[0].DayNightColor=n to be returned in the response. When it is inexplicably missing, the following error results:
This is the video.py code section that throws this error when the result is undefined:
I have no idea why the camera will sometimes not respond with the full expected VideoInOptions API payload. What I typically do to fix this is to reset the firmware to defaults and set it all back up again. So while maybe it can be argued that this is not a bug in the code when the camera API is misbehaving, there really should be a value/range check with a default value created and warning that allows the camera to continue to be set up.
For reference, here is the full response received from the /cgi-bin/configManager.cgi?action=getConfig&name=VideoInOptions command when this error occurs: