Use http status constants more, add HTTP_ACCEPTED and HTTP_BAD_GATEWAY (#39993)
* Use http status codes and add HTTP_BAD_GATEWAY constant * Address review comments: - using constants in tado integration - using constant in media_player init.py * Add and use HTTP_ACCEPTED constant
This commit is contained in:
parent
59d610af17
commit
db582bdc1b
32 changed files with 137 additions and 58 deletions
|
@ -8,7 +8,7 @@ import requests
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_NAME, HTTP_OK
|
||||
from homeassistant.const import CONF_NAME, HTTP_OK, HTTP_UNAUTHORIZED
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
|
@ -67,7 +67,7 @@ class SigfoxAPI:
|
|||
url = urljoin(API_URL, "devicetypes")
|
||||
response = requests.get(url, auth=self._auth, timeout=10)
|
||||
if response.status_code != HTTP_OK:
|
||||
if response.status_code == 401:
|
||||
if response.status_code == HTTP_UNAUTHORIZED:
|
||||
_LOGGER.error("Invalid credentials for Sigfox API")
|
||||
else:
|
||||
_LOGGER.error(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue