Identify cameras in error logs for generic and mjpeg cameras (#33561)

pull/33569/head
Eugenio Panadero 2020-04-03 10:11:08 +02:00 committed by GitHub
parent ae22b5187a
commit d1c1aa518d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -132,7 +132,9 @@ class GenericCamera(Camera):
)
return response.content
except requests.exceptions.RequestException as error:
_LOGGER.error("Error getting camera image: %s", error)
_LOGGER.error(
"Error getting new camera image from %s: %s", self._name, error
)
return self._last_image
self._last_image = await self.hass.async_add_job(fetch)
@ -146,10 +148,12 @@ class GenericCamera(Camera):
response = await websession.get(url, auth=self._auth)
self._last_image = await response.read()
except asyncio.TimeoutError:
_LOGGER.error("Timeout getting image from: %s", self._name)
_LOGGER.error("Timeout getting camera image from %s", self._name)
return self._last_image
except aiohttp.ClientError as err:
_LOGGER.error("Error getting new camera image: %s", err)
_LOGGER.error(
"Error getting new camera image from %s: %s", self._name, err
)
return self._last_image
self._last_url = url

View File

@ -122,10 +122,10 @@ class MjpegCamera(Camera):
return image
except asyncio.TimeoutError:
_LOGGER.error("Timeout getting camera image")
_LOGGER.error("Timeout getting camera image from %s", self._name)
except aiohttp.ClientError as err:
_LOGGER.error("Error getting new camera image: %s", err)
_LOGGER.error("Error getting new camera image from %s: %s", self._name, err)
def camera_image(self):
"""Return a still image response from the camera."""