Fix i/o in august camera async image update (#32044)

* Fix i/o in august camera image update

* Address review comments
This commit is contained in:
J. Nick Koston 2020-02-21 00:39:07 -06:00 committed by GitHub
parent d4075fb262
commit 6e74ee7b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,12 +64,17 @@ class AugustCamera(Camera):
if self._image_url is not latest.image_url: if self._image_url is not latest.image_url:
self._image_url = latest.image_url self._image_url = latest.image_url
self._image_content = requests.get( self._image_content = await self.hass.async_add_executor_job(
self._image_url, timeout=self._timeout self._camera_image
).content )
return self._image_content return self._image_content
def _camera_image(self):
"""Return bytes of camera image via http get."""
# Move this to py-august: see issue#32048
return requests.get(self._image_url, timeout=self._timeout).content
@property @property
def unique_id(self) -> str: def unique_id(self) -> str:
"""Get the unique id of the camera.""" """Get the unique id of the camera."""