Use HTTP_OK constant (#33798)
* Use http ok constant * Remove incorrect use * Run isort * Fix pylint by adding missing imports * Fix pylint by fixing one import
This commit is contained in:
parent
7383e81609
commit
8d61893c39
79 changed files with 214 additions and 154 deletions
|
@ -6,7 +6,7 @@ from pyaftership.tracker import Tracking
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_NAME
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_NAME, HTTP_OK
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
@ -66,7 +66,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
|
||||
await aftership.get_trackings()
|
||||
|
||||
if not aftership.meta or aftership.meta["code"] != 200:
|
||||
if not aftership.meta or aftership.meta["code"] != HTTP_OK:
|
||||
_LOGGER.error(
|
||||
"No tracking data found. Check API key is correct: %s", aftership.meta
|
||||
)
|
||||
|
@ -164,7 +164,7 @@ class AfterShipSensor(Entity):
|
|||
if not self.aftership.meta:
|
||||
_LOGGER.error("Unknown errors when querying")
|
||||
return
|
||||
if self.aftership.meta["code"] != 200:
|
||||
if self.aftership.meta["code"] != HTTP_OK:
|
||||
_LOGGER.error(
|
||||
"Errors when querying AfterShip. %s", str(self.aftership.meta)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue