Use http.HTTPStatus in components/[tuv]* (#58325)
This commit is contained in:
parent
45a98aee10
commit
cc0c79ac9a
14 changed files with 69 additions and 57 deletions
|
@ -1,5 +1,6 @@
|
|||
"""Support for The Things Network's Data storage integration."""
|
||||
import asyncio
|
||||
from http import HTTPStatus
|
||||
import logging
|
||||
|
||||
import aiohttp
|
||||
|
@ -13,8 +14,6 @@ from homeassistant.const import (
|
|||
ATTR_TIME,
|
||||
CONF_DEVICE_ID,
|
||||
CONTENT_TYPE_JSON,
|
||||
HTTP_NOT_FOUND,
|
||||
HTTP_UNAUTHORIZED,
|
||||
)
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -134,15 +133,15 @@ class TtnDataStorage:
|
|||
|
||||
status = response.status
|
||||
|
||||
if status == 204:
|
||||
if status == HTTPStatus.NO_CONTENT:
|
||||
_LOGGER.error("The device is not available: %s", self._device_id)
|
||||
return None
|
||||
|
||||
if status == HTTP_UNAUTHORIZED:
|
||||
if status == HTTPStatus.UNAUTHORIZED:
|
||||
_LOGGER.error("Not authorized for Application ID: %s", self._app_id)
|
||||
return None
|
||||
|
||||
if status == HTTP_NOT_FOUND:
|
||||
if status == HTTPStatus.NOT_FOUND:
|
||||
_LOGGER.error("Application ID is not available: %s", self._app_id)
|
||||
return None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue