Fix uncaught Blink exceptions (#69770)

This commit is contained in:
Kevin Fronczak 2022-04-27 01:22:03 -04:00 committed by GitHub
parent 4a6ea5afd8
commit 4317daaf08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,8 @@ from __future__ import annotations
import logging
from requests.exceptions import ChunkedEncodingError
from homeassistant.components.camera import Camera
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
@ -85,4 +87,11 @@ class BlinkCamera(Camera):
self, width: int | None = None, height: int | None = None
) -> bytes | None:
"""Return a still image response from the camera."""
return self._camera.image_from_cache.content
try:
return self._camera.image_from_cache.content
except ChunkedEncodingError:
_LOGGER.debug("Could not retrieve image for %s", self._camera.name)
return None
except TypeError:
_LOGGER.debug("No cached image for %s", self._camera.name)
return None