From 9520d3828881bc2191da6abd88c707fab58a3857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isabella=20Gross=20Alstr=C3=B6m?= Date: Fri, 15 Mar 2019 18:14:22 +0100 Subject: [PATCH] Update rest.py (#22077) Added specific error logs for 5xx and 4xx responses, debug log for 2xx and other statuses. --- homeassistant/components/notify/rest.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/notify/rest.py b/homeassistant/components/notify/rest.py index bc4341d7b47..469319a0f3e 100644 --- a/homeassistant/components/notify/rest.py +++ b/homeassistant/components/notify/rest.py @@ -139,8 +139,19 @@ class RestNotificationService(BaseNotificationService): params=data, timeout=10, auth=self._auth, verify=self._verify_ssl) - success_codes = (200, 201, 202, 203, 204, 205, 206, 207, 208, 226) - if response.status_code not in success_codes: + if response.status_code >= 500 and response.status_code < 600: _LOGGER.exception( - "Error sending message. Response %d: %s:", + "Server error. Response %d: %s:", + response.status_code, response.reason) + elif response.status_code >= 400 and response.status_code < 500: + _LOGGER.exception( + "Client error. Response %d: %s:", + response.status_code, response.reason) + elif response.status_code >= 200 and response.status_code < 300: + _LOGGER.debug( + "Success. Response %d: %s:", + response.status_code, response.reason) + else: + _LOGGER.debug( + "Response %d: %s:", response.status_code, response.reason)