Use HTTPStatus in components/[nop]* (#58279)

This commit is contained in:
Ville Skyttä 2021-10-23 21:56:30 +03:00 committed by GitHub
parent 5626cc4524
commit 380cff167e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 92 additions and 70 deletions

View file

@ -1,5 +1,6 @@
"""Support for openexchangerates.org exchange rates service."""
from datetime import timedelta
from http import HTTPStatus
import logging
import requests
@ -12,7 +13,6 @@ from homeassistant.const import (
CONF_BASE,
CONF_NAME,
CONF_QUOTE,
HTTP_OK,
)
import homeassistant.helpers.config_validation as cv
from homeassistant.util import Throttle
@ -49,7 +49,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
rest = OpenexchangeratesData(_RESOURCE, parameters, quote)
response = requests.get(_RESOURCE, params=parameters, timeout=10)
if response.status_code != HTTP_OK:
if response.status_code != HTTPStatus.OK:
_LOGGER.error("Check your OpenExchangeRates API key")
return False