From 1adb45f74e96fc5eff137a3727647a7e428e123c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 9 Apr 2020 00:54:02 -0700 Subject: [PATCH] Check status code on onvif snapshot (#33865) --- homeassistant/components/onvif/camera.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/onvif/camera.py b/homeassistant/components/onvif/camera.py index d623f1d879b..299c9026b0e 100644 --- a/homeassistant/components/onvif/camera.py +++ b/homeassistant/components/onvif/camera.py @@ -516,7 +516,8 @@ class ONVIFHassCamera(Camera): """Read image from a URL.""" try: response = requests.get(self._snapshot, timeout=5, auth=auth) - return response.content + if response.status_code < 300: + return response.content except requests.exceptions.RequestException as error: _LOGGER.error( "Fetch snapshot image failed from %s, falling back to FFmpeg; %s",