mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +00:00
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:
@@ -6,7 +6,7 @@ import requests
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchDevice
|
||||
from homeassistant.const import CONF_NAME, CONF_RESOURCE
|
||||
from homeassistant.const import CONF_NAME, CONF_RESOURCE, HTTP_OK
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -116,7 +116,7 @@ class ArestSwitchFunction(ArestSwitchBase):
|
||||
|
||||
request = requests.get(f"{self._resource}/{self._func}", timeout=10)
|
||||
|
||||
if request.status_code != 200:
|
||||
if request.status_code != HTTP_OK:
|
||||
_LOGGER.error("Can't find function")
|
||||
return
|
||||
|
||||
@@ -133,7 +133,7 @@ class ArestSwitchFunction(ArestSwitchBase):
|
||||
f"{self._resource}/{self._func}", timeout=10, params={"params": "1"}
|
||||
)
|
||||
|
||||
if request.status_code == 200:
|
||||
if request.status_code == HTTP_OK:
|
||||
self._state = True
|
||||
else:
|
||||
_LOGGER.error("Can't turn on function %s at %s", self._func, self._resource)
|
||||
@@ -144,7 +144,7 @@ class ArestSwitchFunction(ArestSwitchBase):
|
||||
f"{self._resource}/{self._func}", timeout=10, params={"params": "0"}
|
||||
)
|
||||
|
||||
if request.status_code == 200:
|
||||
if request.status_code == HTTP_OK:
|
||||
self._state = False
|
||||
else:
|
||||
_LOGGER.error(
|
||||
@@ -172,7 +172,7 @@ class ArestSwitchPin(ArestSwitchBase):
|
||||
self.invert = invert
|
||||
|
||||
request = requests.get(f"{self._resource}/mode/{self._pin}/o", timeout=10)
|
||||
if request.status_code != 200:
|
||||
if request.status_code != HTTP_OK:
|
||||
_LOGGER.error("Can't set mode")
|
||||
self._available = False
|
||||
|
||||
@@ -182,7 +182,7 @@ class ArestSwitchPin(ArestSwitchBase):
|
||||
request = requests.get(
|
||||
f"{self._resource}/digital/{self._pin}/{turn_on_payload}", timeout=10
|
||||
)
|
||||
if request.status_code == 200:
|
||||
if request.status_code == HTTP_OK:
|
||||
self._state = True
|
||||
else:
|
||||
_LOGGER.error("Can't turn on pin %s at %s", self._pin, self._resource)
|
||||
@@ -193,7 +193,7 @@ class ArestSwitchPin(ArestSwitchBase):
|
||||
request = requests.get(
|
||||
f"{self._resource}/digital/{self._pin}/{turn_off_payload}", timeout=10
|
||||
)
|
||||
if request.status_code == 200:
|
||||
if request.status_code == HTTP_OK:
|
||||
self._state = False
|
||||
else:
|
||||
_LOGGER.error("Can't turn off pin %s at %s", self._pin, self._resource)
|
||||
|
||||
Reference in New Issue
Block a user