diff --git a/homeassistant/components/abode/camera.py b/homeassistant/components/abode/camera.py index d0f428a45fa..c4c2d0dc78d 100644 --- a/homeassistant/components/abode/camera.py +++ b/homeassistant/components/abode/camera.py @@ -74,7 +74,9 @@ class AbodeCamera(AbodeDevice, Camera): """Attempt to download the most recent capture.""" if self._device.image_url: try: - self._response = requests.get(self._device.image_url, stream=True) + self._response = requests.get( + self._device.image_url, stream=True, timeout=10 + ) self._response.raise_for_status() except requests.HTTPError as err: diff --git a/homeassistant/components/facebox/image_processing.py b/homeassistant/components/facebox/image_processing.py index 21eb91a04a3..5584efb883a 100644 --- a/homeassistant/components/facebox/image_processing.py +++ b/homeassistant/components/facebox/image_processing.py @@ -68,7 +68,7 @@ def check_box_health(url, username, password): if username: kwargs["auth"] = requests.auth.HTTPBasicAuth(username, password) try: - response = requests.get(url, **kwargs) + response = requests.get(url, **kwargs, timeout=10) if response.status_code == HTTPStatus.UNAUTHORIZED: _LOGGER.error("AuthenticationError on %s", CLASSIFIER) return None @@ -116,7 +116,9 @@ def post_image(url, image, username, password): if username: kwargs["auth"] = requests.auth.HTTPBasicAuth(username, password) try: - response = requests.post(url, json={"base64": encode_image(image)}, **kwargs) + response = requests.post( + url, json={"base64": encode_image(image)}, timeout=10, **kwargs + ) if response.status_code == HTTPStatus.UNAUTHORIZED: _LOGGER.error("AuthenticationError on %s", CLASSIFIER) return None @@ -137,6 +139,7 @@ def teach_file(url, name, file_path, username, password): url, data={FACEBOX_NAME: name, ATTR_ID: file_path}, files={"file": open_file}, + timeout=10, **kwargs, ) if response.status_code == HTTPStatus.UNAUTHORIZED: diff --git a/homeassistant/components/llamalab_automate/notify.py b/homeassistant/components/llamalab_automate/notify.py index e2850792906..af0271e107d 100644 --- a/homeassistant/components/llamalab_automate/notify.py +++ b/homeassistant/components/llamalab_automate/notify.py @@ -66,6 +66,6 @@ class AutomateNotificationService(BaseNotificationService): "payload": message, } - response = requests.post(_RESOURCE, json=data) + response = requests.post(_RESOURCE, json=data, timeout=10) if response.status_code != HTTPStatus.OK: _LOGGER.error("Error sending message: %s", response) diff --git a/homeassistant/components/nest/legacy/camera.py b/homeassistant/components/nest/legacy/camera.py index 9974ae2daaa..affe912b6fb 100644 --- a/homeassistant/components/nest/legacy/camera.py +++ b/homeassistant/components/nest/legacy/camera.py @@ -142,7 +142,7 @@ class NestCamera(Camera): url = self.device.snapshot_url try: - response = requests.get(url) + response = requests.get(url, timeout=10) except requests.exceptions.RequestException as error: _LOGGER.error("Error getting camera image: %s", error) return None diff --git a/homeassistant/components/opencv/image_processing.py b/homeassistant/components/opencv/image_processing.py index cde5a8264b8..463b5e0eed1 100644 --- a/homeassistant/components/opencv/image_processing.py +++ b/homeassistant/components/opencv/image_processing.py @@ -87,7 +87,7 @@ def _create_processor_from_config(hass, camera_entity, config): def _get_default_classifier(dest_path): """Download the default OpenCV classifier.""" _LOGGER.info("Downloading default classifier") - req = requests.get(CASCADE_URL, stream=True) + req = requests.get(CASCADE_URL, stream=True, timeout=10) with open(dest_path, "wb") as fil: for chunk in req.iter_content(chunk_size=1024): if chunk: # filter out keep-alive new chunks diff --git a/homeassistant/components/uk_transport/sensor.py b/homeassistant/components/uk_transport/sensor.py index f3c7c5d84a0..28d0fd71142 100644 --- a/homeassistant/components/uk_transport/sensor.py +++ b/homeassistant/components/uk_transport/sensor.py @@ -134,7 +134,7 @@ class UkTransportSensor(SensorEntity): {"app_id": self._api_app_id, "app_key": self._api_app_key}, **params ) - response = requests.get(self._url, params=request_params) + response = requests.get(self._url, params=request_params, timeout=10) if response.status_code != HTTPStatus.OK: _LOGGER.warning("Invalid response from API") elif "error" in response.json(): diff --git a/homeassistant/components/withings/common.py b/homeassistant/components/withings/common.py index 93c3800e42f..11badca8d8c 100644 --- a/homeassistant/components/withings/common.py +++ b/homeassistant/components/withings/common.py @@ -503,6 +503,7 @@ class ConfigEntryWithingsApi(AbstractWithingsApi): f"{self.URL}/{path}", params=params, headers={"Authorization": f"Bearer {access_token}"}, + timeout=10, ) return response.json()