diff --git a/homeassistant/components/august/__init__.py b/homeassistant/components/august/__init__.py index 93b5ec6ec78..468e6e429a7 100644 --- a/homeassistant/components/august/__init__.py +++ b/homeassistant/components/august/__init__.py @@ -1,18 +1,20 @@ """Support for August devices.""" -import logging from datetime import timedelta +import logging +from august.api import Api +from august.authenticator import AuthenticationState, Authenticator, ValidationResult +from requests import RequestException, Session import voluptuous as vol -from requests import RequestException -import homeassistant.helpers.config_validation as cv from homeassistant.const import ( CONF_PASSWORD, - CONF_USERNAME, CONF_TIMEOUT, + CONF_USERNAME, EVENT_HOMEASSISTANT_STOP, ) from homeassistant.helpers import discovery +import homeassistant.helpers.config_validation as cv from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) @@ -62,7 +64,6 @@ def request_configuration(hass, config, api, authenticator): def august_configuration_callback(data): """Run when the configuration callback is called.""" - from august.authenticator import ValidationResult result = authenticator.validate_verification_code(data.get("verification_code")) @@ -94,7 +95,6 @@ def request_configuration(hass, config, api, authenticator): def setup_august(hass, config, api, authenticator): """Set up the August component.""" - from august.authenticator import AuthenticationState authentication = None try: @@ -134,9 +134,6 @@ def setup_august(hass, config, api, authenticator): def setup(hass, config): """Set up the August component.""" - from august.api import Api - from august.authenticator import Authenticator - from requests import Session conf = config[DOMAIN] api_http_session = None diff --git a/homeassistant/components/august/binary_sensor.py b/homeassistant/components/august/binary_sensor.py index d68582d30c5..14d03189c92 100644 --- a/homeassistant/components/august/binary_sensor.py +++ b/homeassistant/components/august/binary_sensor.py @@ -2,6 +2,9 @@ from datetime import datetime, timedelta import logging +from august.activity import ActivityType +from august.lock import LockDoorStatus + from homeassistant.components.binary_sensor import BinarySensorDevice from . import DATA_AUGUST @@ -26,7 +29,6 @@ def _retrieve_online_state(data, doorbell): def _retrieve_motion_state(data, doorbell): - from august.activity import ActivityType return _activity_time_based_state( data, doorbell, [ActivityType.DOORBELL_MOTION, ActivityType.DOORBELL_DING] @@ -34,7 +36,6 @@ def _retrieve_motion_state(data, doorbell): def _retrieve_ding_state(data, doorbell): - from august.activity import ActivityType return _activity_time_based_state(data, doorbell, [ActivityType.DOORBELL_DING]) @@ -65,8 +66,6 @@ def setup_platform(hass, config, add_entities, discovery_info=None): data = hass.data[DATA_AUGUST] devices = [] - from august.lock import LockDoorStatus - for door in data.locks: for sensor_type in SENSOR_TYPES_DOOR: state_provider = SENSOR_TYPES_DOOR[sensor_type][2] @@ -136,8 +135,6 @@ class AugustDoorBinarySensor(BinarySensorDevice): self._state = state_provider(self._data, self._door) self._available = self._state is not None - from august.lock import LockDoorStatus - self._state = self._state == LockDoorStatus.OPEN @property diff --git a/homeassistant/components/august/lock.py b/homeassistant/components/august/lock.py index 8b8c019eb2d..a541be67097 100644 --- a/homeassistant/components/august/lock.py +++ b/homeassistant/components/august/lock.py @@ -2,6 +2,9 @@ from datetime import timedelta import logging +from august.activity import ActivityType +from august.lock import LockStatus + from homeassistant.components.lock import LockDevice from homeassistant.const import ATTR_BATTERY_LEVEL @@ -51,8 +54,6 @@ class AugustLock(LockDevice): self._lock_detail = self._data.get_lock_detail(self._lock.device_id) - from august.activity import ActivityType - activity = self._data.get_latest_device_activity( self._lock.device_id, ActivityType.LOCK_OPERATION ) @@ -73,7 +74,6 @@ class AugustLock(LockDevice): @property def is_locked(self): """Return true if device is on.""" - from august.lock import LockStatus return self._lock_status is LockStatus.LOCKED