Use HTTP_BAD_REQUEST constant (#33797)

This commit is contained in:
springstan authored and GitHub committed 2020-04-09 21:43:42 +02:00
1 parent d510384c0d
commit 4c38e6cfa5
24 files changed
+111 -61

No files matched your search

+2 -1
View File
@@ -21,6 +21,7 @@ from homeassistant.const import (
CONF_RESOURCE,
CONF_USERNAME,
CONF_VERIFY_SSL,
HTTP_BAD_REQUEST,
HTTP_BASIC_AUTHENTICATION,
HTTP_DIGEST_AUTHENTICATION,
HTTP_INTERNAL_SERVER_ERROR,
@@ -197,7 +198,7 @@ class RestNotificationService(BaseNotificationService):
"Server error. Response %d: %s:", response.status_code, response.reason
)
elif (
response.status_code >= 400
response.status_code >= HTTP_BAD_REQUEST
and response.status_code < HTTP_INTERNAL_SERVER_ERROR
):
_LOGGER.exception(
+2 -1
View File
@@ -16,6 +16,7 @@ from homeassistant.const import (
CONF_TIMEOUT,
CONF_USERNAME,
CONF_VERIFY_SSL,
HTTP_BAD_REQUEST,
HTTP_OK,
)
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@@ -95,7 +96,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
)
req = await switch.get_device_state(hass)
if req.status >= 400:
if req.status >= HTTP_BAD_REQUEST:
_LOGGER.error("Got non-ok response from resource: %s", req.status)
else:
async_add_entities([switch])