Use http.HTTPStatus in components/[tuv]* (#58325)

This commit is contained in:
Ville Skyttä 2021-10-24 12:27:17 +03:00 committed by GitHub
parent 45a98aee10
commit cc0c79ac9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 69 additions and 57 deletions

View file

@ -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