diff --git a/homeassistant/components/switch/arest.py b/homeassistant/components/switch/arest.py index ec04e3c210f..4feb8a5d691 100644 --- a/homeassistant/components/switch/arest.py +++ b/homeassistant/components/switch/arest.py @@ -8,7 +8,7 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/switch.arest.html """ import logging -from requests import get, exceptions +import requests from homeassistant.components.switch import SwitchDevice from homeassistant.const import DEVICE_DEFAULT_NAME @@ -22,12 +22,12 @@ def setup_platform(hass, config, add_devices, discovery_info=None): resource = config.get('resource', None) try: - response = get(resource, timeout=10) - except exceptions.MissingSchema: + response = requests.get(resource, timeout=10) + except requests.exceptions.MissingSchema: _LOGGER.error("Missing resource or schema in configuration. " "Add http:// to your URL.") return False - except exceptions.ConnectionError: + except requests.exceptions.ConnectionError: _LOGGER.error("No route to device. " "Please check the IP address in the configuration file.") return False @@ -52,8 +52,8 @@ class ArestSwitch(SwitchDevice): self._pin = pin self._state = None - request = get('{}/mode/{}/o'.format(self._resource, self._pin), - timeout=10) + request = requests.get('{}/mode/{}/o'.format(self._resource, + self._pin), timeout=10) if request.status_code is not 200: _LOGGER.error("Can't set mode. Is device offline?") @@ -69,8 +69,8 @@ class ArestSwitch(SwitchDevice): def turn_on(self, **kwargs): """ Turn the device on. """ - request = get('{}/digital/{}/1'.format(self._resource, self._pin), - timeout=10) + request = requests.get('{}/digital/{}/1'.format(self._resource, + self._pin), timeout=10) if request.status_code == 200: self._state = True else: @@ -79,8 +79,8 @@ class ArestSwitch(SwitchDevice): def turn_off(self, **kwargs): """ Turn the device off. """ - request = get('{}/digital/{}/0'.format(self._resource, self._pin), - timeout=10) + request = requests.get('{}/digital/{}/0'.format(self._resource, + self._pin), timeout=10) if request.status_code == 200: self._state = False else: @@ -89,6 +89,6 @@ class ArestSwitch(SwitchDevice): def update(self): """ Gets the latest data from aREST API and updates the state. """ - request = get('{}/digital/{}'.format(self._resource, self._pin), - timeout=10) + request = requests.get('{}/digital/{}'.format(self._resource, + self._pin), timeout=10) self._state = request.json()['return_value'] != 0